-
-
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
0a0a9f7
commit 6f9e982
Showing
10 changed files
with
319 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/** | ||
* 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, stderr, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(``); | ||
}); | ||
|
||
test('prints coverage with empty sourcemaps', () => { | ||
const sourcemapDir = path.join(DIR, 'empty-sourcemap'); | ||
|
||
const {stdout, stderr, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(``); | ||
}); | ||
|
||
test('reports coverage with `resetModules`', () => { | ||
const sourcemapDir = path.join(DIR, 'with-resetModules'); | ||
|
||
const {stdout, stderr, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(stderr).toEqual(``); | ||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(``); | ||
}); | ||
|
||
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, stderr, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(stderr).toEqual(``); | ||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(``); | ||
}); | ||
|
||
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, stderr, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(stderr).toEqual(``); | ||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(``); | ||
}); | ||
|
||
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, stderr, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{ | ||
nodeOptions: '--experimental-vm-modules --no-warnings', | ||
stripAnsi: true, | ||
}, | ||
); | ||
|
||
expect(stderr).toEqual(``); | ||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(``); | ||
}); | ||
|
||
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, stderr, exitCode} = runJest( | ||
sourcemapDir, | ||
['--coverage', '--coverage-provider', 'odz', '--no-cache'], | ||
{ | ||
nodeOptions: '--experimental-vm-modules --no-warnings', | ||
stripAnsi: true, | ||
}, | ||
); | ||
|
||
expect(stderr).toEqual(``); | ||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(` 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 | 0 | 0 | 0 | 0 | 14-15,19 | ||
types.ts | 0 | 0 | 0 | 0 | | ||
uncovered.ts | 0 | 0 | 0 | 0 | | ||
--------------|---------|----------|---------|---------|-------------------`); | ||
}); | ||
|
||
test('vm script coverage generator', () => { | ||
const dir = path.resolve(__dirname, '../vmscript-coverage'); | ||
const {stdout, stderr, exitCode} = runJest( | ||
dir, | ||
['--coverage', '--coverage-provider', 'odz'], | ||
{stripAnsi: true}, | ||
); | ||
|
||
expect(stderr).toEqual(``); | ||
expect(exitCode).toBe(0); | ||
expect(stdout).toEqual(`-------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s· | ||
-------------|---------|----------|---------|---------|------------------- | ||
All files | 80 | 75 | 66.66 | 80 | | ||
vmscript.js | 80 | 75 | 66.66 | 80 | 20-21 | ||
-------------|---------|----------|---------|---------|-------------------`); | ||
}); |
1 change: 1 addition & 0 deletions
1
...-v8/esm-with-custom-transformer/.odz_output/.coverage/coverage-13419-1729711730560-0.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...verage-provider-v8/no-sourcemap/.odz_output/.coverage/coverage-12604-1729707983038-0.json
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -204,5 +204,8 @@ | |
"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" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"one-double-zero": "^1.0.0-beta.11" | ||
} | ||
} |
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
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.