Installations
npm install @wistudent/jest-each-improved-types
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Node Version
18.14.1
NPM Version
9.3.1
Score
50.5
Supply Chain
62.8
Quality
72.1
Maintenance
100
Vulnerability
97.9
License
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.03%)
JavaScript (0.97%)
Developer
WIStudent
Download Statistics
Total Downloads
82,596
Last Day
37
Last Week
277
Last Month
1,391
Last Year
39,905
GitHub Statistics
2 Stars
537 Commits
2 Watching
2 Branches
1 Contributors
Bundle Size
208.00 B
Minified
159.00 B
Minified + Gzipped
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
82,596
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
3
Dev Dependencies
5
jest-each-improved-types
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.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
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
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release-please.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/WIStudent/jest-each-improved-types/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-please.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/WIStudent/jest-each-improved-types/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-please.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/WIStudent/jest-each-improved-types/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/WIStudent/jest-each-improved-types/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/WIStudent/jest-each-improved-types/test.yml/master?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 2 out of 2 npmCommand dependencies pinned
Reason
6 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
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
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release-please.yml:12
- Warn: no topLevel permission defined: .github/workflows/release-please.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 21 are checked with a SAST tool
Score
2.9
/10
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