-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add One Double Zero as coverage provider #15356
Open
ericmorand
wants to merge
1
commit into
jestjs:main
Choose a base branch
from
ericmorand:odz
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
e2e/__tests__/__snapshots__/coverageProviderODZ.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`prints correct coverage report, if a CJS module is put under test without transformation 1`] = ` | ||
" console.log | ||
this will print | ||
|
||
at covered (module.js:11:11) | ||
|
||
--------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
--------------|---------|----------|---------|---------|------------------- | ||
All files | 60 | 50 | 50 | 60 | | ||
module.js | 66.66 | 50 | 50 | 66.66 | 14-15,19 | ||
uncovered.js | 0 | 100 | 100 | 0 | 8 | ||
--------------|---------|----------|---------|---------|-------------------" | ||
`; | ||
|
||
exports[`prints correct coverage report, if a TS module is transpiled by Babel to CJS and put under test 1`] = ` | ||
" console.log | ||
this will print | ||
|
||
at log (module.ts:13:11) | ||
|
||
--------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
--------------|---------|----------|---------|---------|------------------- | ||
All files | 62.5 | 50 | 50 | 62.5 | | ||
module.ts | 62.5 | 50 | 50 | 62.5 | 16-17,21 | ||
types.ts | 0 | 0 | 0 | 0 | | ||
uncovered.ts | 0 | 0 | 0 | 0 | | ||
--------------|---------|----------|---------|---------|-------------------" | ||
`; | ||
|
||
exports[`prints correct coverage report, if a TS module is transpiled by custom transformer to ESM put under test 1`] = ` | ||
" console.log | ||
this will print | ||
|
||
at covered (module.ts:13:11) | ||
|
||
--------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
--------------|---------|----------|---------|---------|------------------- | ||
All files | 62.5 | 50 | 50 | 62.5 | | ||
module.ts | 62.5 | 50 | 50 | 62.5 | 16-17,21 | ||
types.ts | 0 | 0 | 0 | 0 | | ||
uncovered.ts | 0 | 0 | 0 | 0 | | ||
--------------|---------|----------|---------|---------|-------------------" | ||
`; | ||
|
||
exports[`prints correct coverage report, if an ESM module is put under test without transformation 1`] = ` | ||
" console.log | ||
this will print | ||
|
||
at covered (module.js:11:11) | ||
|
||
--------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
--------------|---------|----------|---------|---------|------------------- | ||
All files | 62.5 | 50 | 50 | 62.5 | | ||
module.js | 62.5 | 50 | 50 | 62.5 | 14-15,19 | ||
uncovered.js | 0 | 0 | 0 | 0 | | ||
--------------|---------|----------|---------|---------|-------------------" | ||
`; | ||
|
||
exports[`prints coverage with empty sourcemaps 1`] = ` | ||
"----------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
----------|---------|----------|---------|---------|------------------- | ||
All files | 0 | 0 | 0 | 0 | | ||
types.ts | 0 | 0 | 0 | 0 | | ||
----------|---------|----------|---------|---------|-------------------" | ||
`; | ||
|
||
exports[`prints coverage with missing sourcemaps 1`] = ` | ||
" console.log | ||
42 | ||
|
||
at Object.log (__tests__/Thing.test.js:10:9) | ||
|
||
----------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
----------|---------|----------|---------|---------|------------------- | ||
All files | 100 | 100 | 100 | 100 | | ||
Thing.js | 100 | 100 | 100 | 100 | | ||
x.css | 0 | 0 | 0 | 0 | | ||
----------|---------|----------|---------|---------|-------------------" | ||
`; | ||
|
||
exports[`reports coverage with \`resetModules\` 1`] = ` | ||
" console.log | ||
this will print | ||
|
||
at log (module.js:11:11) | ||
|
||
console.log | ||
this will print | ||
|
||
at log (module.js:11:11) | ||
|
||
--------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
--------------|---------|----------|---------|---------|------------------- | ||
All files | 60 | 50 | 50 | 60 | | ||
module.js | 66.66 | 50 | 50 | 66.66 | 14-15,19 | ||
uncovered.js | 0 | 100 | 100 | 0 | 8 | ||
--------------|---------|----------|---------|---------|-------------------" | ||
`; | ||
|
||
exports[`vm script coverage generator 1`] = ` | ||
"-------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
-------------|---------|----------|---------|---------|------------------- | ||
All files | 80 | 75 | 66.66 | 80 | | ||
vmscript.js | 80 | 75 | 66.66 | 80 | 20-21 | ||
-------------|---------|----------|---------|---------|-------------------" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import * as path from 'path'; | ||
import runJest from '../runJest'; | ||
|
||
const DIR = path.resolve(__dirname, '../coverage-provider-v8'); | ||
|
||
test('prints coverage with missing sourcemaps', () => { | ||
const sourcemapDir = path.join(DIR, 'no-sourcemap'); | ||
|
||
const {stdout, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('prints coverage with empty sourcemaps', () => { | ||
const sourcemapDir = path.join(DIR, 'empty-sourcemap'); | ||
|
||
const {stdout, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('reports coverage with `resetModules`', () => { | ||
const sourcemapDir = path.join(DIR, 'with-resetModules'); | ||
|
||
const {stdout, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('prints correct coverage report, if a CJS module is put under test without transformation', () => { | ||
const sourcemapDir = path.join(DIR, 'cjs-native-without-sourcemap'); | ||
|
||
const {stdout, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('prints correct coverage report, if a TS module is transpiled by Babel to CJS and put under test', () => { | ||
const sourcemapDir = path.join(DIR, 'cjs-with-babel-transformer'); | ||
|
||
const {stdout, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('prints correct coverage report, if an ESM module is put under test without transformation', () => { | ||
const sourcemapDir = path.join(DIR, 'esm-native-without-sourcemap'); | ||
|
||
const {stdout, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{ | ||
nodeOptions: '--experimental-vm-modules --no-warnings', | ||
stripAnsi: true, | ||
}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('prints correct coverage report, if a TS module is transpiled by custom transformer to ESM put under test', () => { | ||
const sourcemapDir = path.join(DIR, 'esm-with-custom-transformer'); | ||
|
||
const {stdout, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{ | ||
nodeOptions: '--experimental-vm-modules --no-warnings', | ||
stripAnsi: true, | ||
}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('vm script coverage generator', () => { | ||
const dir = path.resolve(__dirname, '../vmscript-coverage'); | ||
const {stdout, exitCode} = runJest( | ||
dir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,7 +202,8 @@ | |
"jest": "workspace:*", | ||
"jest-environment-node": "workspace:*", | ||
"psl": "patch:psl@npm:^1.9.0#./.yarn/patches/psl-npm-1.9.0-a546edad1a.patch", | ||
"ts-node@^10.5.0": "patch:ts-node@npm:^10.5.0#./.yarn/patches/ts-node-npm-10.9.1-6c268be7f4.patch" | ||
"ts-node@^10.5.0": "patch:ts-node@npm:^10.5.0#./.yarn/patches/ts-node-npm-10.9.1-6c268be7f4.patch", | ||
"typescript": "~5.5.4" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
"jest-message-util": "workspace:*", | ||
"jest-util": "workspace:*", | ||
"jest-worker": "workspace:*", | ||
"one-double-zero": "1.0.0-beta.14", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems v1 stable is out? |
||
"slash": "^3.0.0", | ||
"string-length": "^4.0.1", | ||
"strip-ansi": "^6.0.0", | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be here