Gathering detailed insights and metrics for jest-test-each
Gathering detailed insights and metrics for jest-test-each
Gathering detailed insights and metrics for jest-test-each
Gathering detailed insights and metrics for jest-test-each
npm install jest-test-each
Typescript
Module System
Node Version
NPM Version
77.9
Supply Chain
98.7
Quality
76
Maintenance
100
Vulnerability
100
License
TypeScript (99.39%)
JavaScript (0.61%)
Total Downloads
46,834
Last Day
28
Last Week
291
Last Month
10,550
Last Year
35,539
3 Stars
143 Commits
1 Watching
5 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.9.1
Package Id
jest-test-each@0.9.1
Unpacked Size
176.04 kB
Size
23.18 kB
File Count
64
NPM Version
7.0.14
Node Version
14.18.1
Cumulative downloads
Total Downloads
Last day
-93.8%
28
Compared to previous day
Last week
-90.6%
291
Compared to previous week
Last month
-19.9%
10,550
Compared to previous month
Last year
589.4%
35,539
Compared to previous year
This package will help you to run parametrised tests easily [typesafe] without text tables or arrays of arrays.
You can see demo project here.
Tests are here.
1its('roundings') 2 .each([ 3 { input: 0, expected: '0' }, 4 { input: 0.99, expected: '1' }, 5 { input: 102.99998, expected: '103' }, 6 { input: -6, expected: '-6' }, 7 ]) 8 .run(t => { 9 expect(Math.round(t.input).toFixed(0)).toBe(t.expected); 10 });
Run test in idea with jest plugin:
1its('check calculator') 2 .each([ 3 { a: 1, b: 2, exp: [3, -1, 2, 0.5] }, 4 { a: 1, b: 0, exp: [1, 1, 0, Infinity] }, 5 ]) 6 .each(t => [ 7 { sign: '+' as const, exp: t.exp[0] }, 8 { sign: '-' as const, exp: t.exp[1] }, 9 { sign: '*' as const, exp: t.exp[2] }, 10 { sign: '/' as const, exp: t.exp[3] }, 11 ]) 12 .each(t => [{ flatDesc: `${t.a} ${t.sign} ${t.b} should be ${t.exp}` }]) 13 .run(async t => { 14 expect(calc(t.a, t.b, t.sign)).toBe(t.exp); 15 });
and the same test with auto cases names:
Install dev dependency:
yarn add -D jest-test-each
To setup jest you need to have jest.config.js config (official details)
In your jest.config.js config add:
1// jest.config.js 2module.exports = { 3 ... 4 setupFilesAfterEnv: ["./config/setup.js"], 5 ... 6};
In './config/setup.js' file add the following (this is required for global vars to be available):
require('jest-test-each');
for .ts tests to see globals 'its' and 'Test' add the following to your tsconfig:
// tsconfig.json
"include": [
...
"node_modules/jest-test-each/dist/index.d.ts"
]
You can override test runner environment (by default it is jest env) by the following:
1TestEachEnv({ 2 describe: describe, 3 it: it, 4 beforeAll: beforeAll, 5 ... 6});
.each().each()....run()
)its('foo').run(..)
).only(<filter>)
) (example).See example.
Running the feature containing this will result in 2 tests
1 its('Simple test: roundings') 2 .each([ 3 { input: 0, expected: '0' }, 4 { input: 0.99, expected: '1' }, 5 { input: 102.99998, expected: '103' }, 6 { input: -6, expected: '-6' }, 7 ]) 8 .only(t => t.input === -6) 9 .run(t => { 10 expect(Math.round(t.input).toFixed(0)).toBe(t.expected); 11 });
Supporting jest 27.
Working with Skip and Defect:
1 test-runner: "jest-jasmine2"
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
15 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morejest-each
Parameterised tests for Jest
eslint-plugin-jest-test-each-formatting
ESLint rules for formatting jest test.each
jest-plugin-for-each
Jest plugin to test multiple values for a single outcome.
@knapsack-pro/jest
Knapsack Pro Jest splits Jest tests across CI nodes and makes sure that tests will run in optimal time on each CI node.