test.each() doesn't exist in tests using Jest 23.2 and Angular 6 with jest-preset-angular.
[email protected] [email protected] @types/[email protected].package.json add jest settings: "jest": {
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "<rootDir>/src/setupJest.ts",
"collectCoverage": true,
"coverageReporters": [
"html"
]
}
src directory add setupJest.ts:import 'jest-preset-angular';
Error['stackTraceLimit'] = 4;
test.each() should run tests by passed cases.
Please provide either a repl.it demo or a minimal repository on GitHub.
Issues without a reproduction link are likely to stall.
npx envinfo --preset jestPaste the results here:
System:
OS: Linux 4.15 Ubuntu 18.04 LTS (Bionic Beaver)
CPU: x64 Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
Binaries:
Node: 8.11.1 - /usr/local/bin/node
npm: 6.0.1 - /usr/local/bin/npm
npmPackages:
@types/jest: 23.1.4 => 23.1.4
jest: ^23.2.0 => 23.2.0
This issue belongs to jest-preset-angular.
@thymikee I have the same problem and I am using react.
@mattphillips well, yes. and you're right. I just wanted to make sure, that this isn't really belonging to jest-preset-angular alone. I think there are more projects with this issue when it comes to jest@23. I will give jest-each a try though. Thanks
manually installing jest-each did not work for me
@leojh when you manually install jest-each it has a different syntax to test.each, instead you import it in your test file and use it like:
import each from 'jest-each';
each([1, 2, 3]).test('%s should be greater than zero', value => expect(value).toBeGreaterThan(0));
See the docs here: https://github.com/facebook/jest/tree/master/packages/jest-each
any progress on this? (using 23.6)
@thymikee Plz reopen - I can confirm this in React with Jest 23.6.0
@dmwelch jest-each has been part of all releases in Jest since Jest@23. Here's the release for the 23.6 version: https://www.npmjs.com/package/jest-each/v/23.6.0. I actually still use Jest 23.6.0 for quite a few projects and have no issues with this.
Are you able to create a small repo with the issue? I suspect that it may just be a config issue i.e. installing Jest@22 🤷♂️
That was my first thought, so I checked my jest version in package.json:
"jest": "23.6.0",
No cigar there, but my jest-cli is installed at "~22.4.2" - doesn't seem like that should make a difference. I'll work on a test repo tomorrow, if I can get around to it. Cheers!
Most helpful comment
@thymikee I have the same problem and I am using react.