Gathering detailed insights and metrics for @wistudent/jest-each-improved-types
Gathering detailed insights and metrics for @wistudent/jest-each-improved-types
npm install @wistudent/jest-each-improved-types
Typescript
Module System
Node Version
NPM Version
50.5
Supply Chain
62.8
Quality
72.1
Maintenance
100
Vulnerability
97.9
License
TypeScript (99.03%)
JavaScript (0.97%)
Total Downloads
82,596
Last Day
37
Last Week
277
Last Month
1,391
Last Year
39,905
2 Stars
537 Commits
2 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.1.0
Package Id
@wistudent/jest-each-improved-types@2.1.0
Unpacked Size
5.12 kB
Size
1.92 kB
File Count
4
NPM Version
9.3.1
Node Version
18.14.1
Publised On
25 Feb 2023
Cumulative downloads
Total Downloads
Last day
15.6%
37
Compared to previous day
Last week
-29.7%
277
Compared to previous week
Last month
-12.8%
1,391
Compared to previous month
Last year
63.9%
39,905
Compared to previous year
3
5
When using .each
with the table notation, it is possible to set the type of the test function argument on the .each
function as a generic argument:
1import {test, expect} from "@jest/globals"; 2 3test.each<{a: string, b: number, expected: boolean}>` 4a | b | expected 5${'1'} | ${1} | ${true} 6${'1'} | ${2} | ${false} 7`('some test', ({a, b, expected}) => { 8 expect(a === `${b}`).toBe(expected) 9});
But this only sets the type for the test function argument, it does not ensure that the correct values were used inside the table. The following does not result in a typescript error:
1import {test, expect} from "@jest/globals"; 2 3test.each<{a: string, b: number, expected: boolean}>` 4a | b | expected 5${undefined} | ${{}} | ${null} 6`('some test', ({a, b, expected}) => { 7 expect(a === `${b}`).toBe(expected) 8});
This package adds an additional way of providing type definitons to .each
table tests that ensures that the values used inside the table are compatible with the provided typescript types. It does by reexporting @jest/globals
and extending the type definition of the .each
function.
1import {test, expect} from "@wistudent/jest-each-improved-types" 2 3test.each<[['a', string], ['b', number], ['expected', boolean]], 2>` 4a | b | expected 5${'1'} | ${1} | ${true} 6${'1'} | ${2} | ${false} 7`('some test', ({a, b, expected}) => { 8 expect(a === `${b}`).toBe(expected) 9});
Instead of using an interface as the generic argument, a tuple of Key-Type pairs and the number of rows is used. Using a value with the wrong type inside the table, or the number of values not being (Number of Key-Type pairs * Declared number of rows), will result in a typescript error.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
6 existing vulnerabilities detected
Details
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
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
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 More