-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add One Double Zero as coverage provider
- Loading branch information
1 parent
22029ba
commit 856dbb1
Showing
13 changed files
with
472 additions
and
17 deletions.
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
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
Oops, something went wrong.