Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest Error "test.each is not a function" #4845

Closed
eins78 opened this issue Aug 2, 2018 · 2 comments
Closed

jest Error "test.each is not a function" #4845

eins78 opened this issue Aug 2, 2018 · 2 comments

Comments

@eins78
Copy link

eins78 commented Aug 2, 2018

Is this a bug report?

(write your answer here)

Yes.

Did you try recovering your dependencies?

Yes, tried it with a newly created project.

Which terms did you search for in User Guide?

jest, .each

Environment

Environment:
  OS:  macOS High Sierra 10.13.6
  Node:  8.9.2
  Yarn:  1.7.0
  npm:  6.2.0
  Watchman:  4.9.0
  Xcode:  Xcode 9.4.1 Build version 9F2000
  Android Studio:  Not Found

Packages: (wanted => installed)
  react: ^16.4.2 => 16.4.2
  react-dom: ^16.4.2 => 16.4.2
  react-scripts: 1.1.4 => 1.1.4

Steps to Reproduce

npx create-react-app jest-each-bug
cd jest-each-bug/
echo 'test.each([1])('t', a => expect(a).toBe(1))' > src/some.test.js
CI=true npm run test

Expected Behavior

Test should run.

Actual Behavior

💣 TypeError: test.each is not a function

console output

> [email protected] test /private/tmp/jest-each-bug
> react-scripts test --env=jsdom

 PASS  src/App.test.js
 FAIL  src/some.test.js
  ● Test suite failed to run

    TypeError: test.each is not a function

      at Object.<anonymous> (src/some.test.js:1:108)
          at <anonymous>

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.129s
Ran all test suites.

Reproducible Demo

See "Steps to Reproduce" above, creates demo project.

@skoging
Copy link
Contributor

skoging commented Aug 2, 2018

This was added in Jest 23.
create-react-app is on version 20.0.4 in master and 22.4.3 in next.

jest-each is still available as a separate package, but the syntax is a bit different:

npx create-react-app jest-each-bug
cd jest-each-bug/
yarn add jest-each
echo "import each from 'jest-each'; each([1]).test('t', a => expect(a).toBe(1))" > src/some.test.js
CI=true npm run test
 PASS  src/App.test.js
 PASS  src/some.test.js

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        3.776s
Ran all test suites.

@Timer
Copy link
Contributor

Timer commented Sep 21, 2018

Jest 23 will be out with v2.

@Timer Timer closed this as completed Sep 21, 2018
@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants