| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 28a775b commit 63563f8
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -440,6 +440,17 @@ the ability to import a directory that has an index file. | |||
| 440 | 440 | ||
| 441 | 441 | See [customizing ESM specifier resolution][] for example usage. | |
| 442 | 442 | ||
| 443 | + ### `--experimental-test-coverage` | ||
| 444 | + | ||
| 445 | + <!-- YAML | ||
| 446 | + added: REPLACEME | ||
| 447 | + --> | ||
| 448 | + | ||
| 449 | + When used in conjunction with the `node:test` module, a code coverage report is | ||
| 450 | + generated as part of the test runner output. If no tests are run, a coverage | ||
| 451 | + report is not generated. See the documentation on | ||
| 452 | + [collecting code coverage from tests][] for more details. | ||
| 453 | + | ||
| 443 | 454 | ### `--experimental-vm-modules` | |
| 444 | 455 | ||
| 445 | 456 | <!-- YAML | |
@@ -1209,17 +1220,6 @@ Starts the Node.js command line test runner. This flag cannot be combined with | |||
| 1209 | 1220 | See the documentation on [running tests from the command line][] | |
| 1210 | 1221 | for more details. | |
| 1211 | 1222 | ||
| 1212 | - ### `--test-coverage` | ||
| 1213 | - | ||
| 1214 | - <!-- YAML | ||
| 1215 | - added: REPLACEME | ||
| 1216 | - --> | ||
| 1217 | - | ||
| 1218 | - When used in conjunction with the `node:test` module, a code coverage report is | ||
| 1219 | - generated as part of the test runner output. If no tests are run, a coverage | ||
| 1220 | - report is not generated. See the documentation on | ||
| 1221 | - [collecting code coverage from tests][] for more details. | ||
| 1222 | - | ||
| 1223 | 1223 | ### `--test-name-pattern` | |
| 1224 | 1224 | ||
| 1225 | 1225 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -370,13 +370,14 @@ internally. | |||
| 370 | 370 | ||
| 371 | 371 | ## Collecting code coverage | |
| 372 | 372 | ||
| 373 | - When Node.js is started with the [`--test-coverage`][] command-line flag, code | ||
| 374 | - coverage is collected and statistics are reported once all tests have completed. | ||
| 375 | - If the [`NODE_V8_COVERAGE`][] environment variable is used to specify a | ||
| 376 | - code coverage directory, the generated V8 coverage files are written to that | ||
| 377 | - directory. Node.js core modules and files within `node_modules/` directories | ||
| 378 | - are not included in the coverage report. If coverage is enabled, the coverage | ||
| 379 | - report is sent to any [test reporters][] via the `'test:coverage'` event. | ||
| 373 | + When Node.js is started with the [`--experimental-test-coverage`][] | ||
| 374 | + command-line flag, code coverage is collected and statistics are reported once | ||
| 375 | + all tests have completed. If the [`NODE_V8_COVERAGE`][] environment variable is | ||
| 376 | + used to specify a code coverage directory, the generated V8 coverage files are | ||
| 377 | + written to that directory. Node.js core modules and files within | ||
| 378 | + `node_modules/` directories are not included in the coverage report. If | ||
| 379 | + coverage is enabled, the coverage report is sent to any [test reporters][] via | ||
| 380 | + the `'test:coverage'` event. | ||
| 380 | 381 | ||
| 381 | 382 | Coverage can be disabled on a series of lines using the following | |
| 382 | 383 | comment syntax: | |
@@ -411,7 +412,8 @@ which will be addressed in a future Node.js release: | |||
| 411 | 412 | ||
| 412 | 413 | * Although coverage data is collected for child processes, this information is | |
| 413 | 414 | not included in the coverage report. Because the command line test runner uses | |
| 414 | - child processes to execute test files, it cannot be used with `--test-coverage`. | ||
| 415 | + child processes to execute test files, it cannot be used with | ||
| 416 | + `--experimental-test-coverage`. | ||
| 415 | 417 | * Source maps are not supported. | |
| 416 | 418 | * Excluding specific files or directories from the coverage report is not | |
| 417 | 419 | supported. | |
@@ -1634,7 +1636,7 @@ added: v18.7.0 | |||
| 1634 | 1636 | aborted. | |
| 1635 | 1637 | ||
| 1636 | 1638 | [TAP]: https://testanything.org/ | |
| 1637 | - [`--test-coverage`]: cli.md#--test-coverage | ||
| 1639 | + [`--experimental-test-coverage`]: cli.md#--experimental-test-coverage | ||
| 1638 | 1640 | [`--test-name-pattern`]: cli.md#--test-name-pattern | |
| 1639 | 1641 | [`--test-only`]: cli.md#--test-only | |
| 1640 | 1642 | [`--test-reporter-destination`]: cli.md#--test-reporter-destination | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -163,6 +163,9 @@ Use the specified file as a security policy. | |||
| 163 | 163 | .It Fl -experimental-shadow-realm | |
| 164 | 164 | Use this flag to enable ShadowRealm support. | |
| 165 | 165 | . | |
| 166 | + .It Fl -experimental-test-coverage | ||
| 167 | + Enable code coverage in the test runner. | ||
| 168 | + . | ||
| 166 | 169 | .It Fl -no-experimental-fetch | |
| 167 | 170 | Disable experimental support for the Fetch API. | |
| 168 | 171 | . | |
@@ -391,9 +394,6 @@ Specify the minimum allocation from the OpenSSL secure heap. The default is 2. T | |||
| 391 | 394 | .It Fl -test | |
| 392 | 395 | Starts the Node.js command line test runner. | |
| 393 | 396 | . | |
| 394 | - .It Fl -test-coverage | ||
| 395 | - Enable code coverage in the test runner. | ||
| 396 | - . | ||
| 397 | 397 | .It Fl -test-name-pattern | |
| 398 | 398 | A regular expression that configures the test runner to only execute tests | |
| 399 | 399 | whose name matches the provided pattern. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -285,8 +285,10 @@ function setupCodeCoverage() { | |||
| 285 | 285 | // Resolve the coverage directory to an absolute path, and | |
| 286 | 286 | // overwrite process.env so that the original path gets passed | |
| 287 | 287 | // to child processes even when they switch cwd. Don't do anything if the | |
| 288 | - // --test-coverage flag is present, as the test runner will handle coverage. | ||
| 289 | - if (process.env.NODE_V8_COVERAGE && !getOptionValue('--test-coverage')) { | ||
| 288 | + // --experimental-test-coverage flag is present, as the test runner will | ||
| 289 | + // handle coverage. | ||
| 290 | + if (process.env.NODE_V8_COVERAGE && | ||
| 291 | + !getOptionValue('--experimental-test-coverage')) { | ||
| 290 | 292 | process.env.NODE_V8_COVERAGE = | |
| 291 | 293 | setupCoverageHooks(process.env.NODE_V8_COVERAGE); | |
| 292 | 294 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,7 +55,7 @@ function createProcessEventHandler(eventName, rootTest) { | |||
| 55 | 55 | } | |
| 56 | 56 | ||
| 57 | 57 | function configureCoverage(rootTest) { | |
| 58 | - if (!getOptionValue('--test-coverage')) { | ||
| 58 | + if (!getOptionValue('--experimental-test-coverage')) { | ||
| 59 | 59 | return null; | |
| 60 | 60 | } | |
| 61 | 61 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ const { | |||
| 48 | 48 | triggerUncaughtException, | |
| 49 | 49 | } = internalBinding('errors'); | |
| 50 | 50 | ||
| 51 | - const kFilterArgs = ['--test', '--test-coverage', '--watch']; | ||
| 51 | + const kFilterArgs = ['--test', '--experimental-test-coverage', '--watch']; | ||
| 52 | 52 | const kFilterArgValues = ['--test-reporter', '--test-reporter-destination']; | |
| 53 | 53 | ||
| 54 | 54 | // TODO(cjihrig): Replace this with recursive readdir once it lands. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,7 +151,8 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors, | |||
| 151 | 151 | if (test_runner_coverage) { | |
| 152 | 152 | // TODO(cjihrig): This restriction can be removed once multi-process | |
| 153 | 153 | // code coverage is supported. | |
| 154 | - errors->push_back("--test-coverage cannot be used with --test"); | ||
| 154 | + errors->push_back( | ||
| 155 | + "--experimental-test-coverage cannot be used with --test"); | ||
| 155 | 156 | } | |
| 156 | 157 | ||
| 157 | 158 | if (syntax_check_only) { | |
@@ -561,7 +562,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | |||
| 561 | 562 | AddOption("--test", | |
| 562 | 563 | "launch test runner on startup", | |
| 563 | 564 | &EnvironmentOptions::test_runner); | |
| 564 | - AddOption("--test-coverage", | ||
| 565 | + AddOption("--experimental-test-coverage", | ||
| 565 | 566 | "enable code coverage in the test runner", | |
| 566 | 567 | &EnvironmentOptions::test_runner_coverage); | |
| 567 | 568 | AddOption("--test-name-pattern", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,15 +37,17 @@ function getCoverageFixtureReport() { | |||
| 37 | 37 | return report; | |
| 38 | 38 | } | |
| 39 | 39 | ||
| 40 | - test('--test-coverage and --test cannot be combined', () => { | ||
| 40 | + test('--experimental-test-coverage and --test cannot be combined', () => { | ||
| 41 | 41 | // TODO(cjihrig): This test can be removed once multi-process code coverage | |
| 42 | 42 | // is supported. | |
| 43 | - const result = spawnSync(process.execPath, ['--test', '--test-coverage']); | ||
| 43 | + const args = ['--test', '--experimental-test-coverage']; | ||
| 44 | + const result = spawnSync(process.execPath, args); | ||
| 44 | 45 | ||
| 45 | 46 | // 9 is the documented exit code for an invalid CLI argument. | |
| 46 | 47 | assert.strictEqual(result.status, 9); | |
| 47 | 48 | assert.match( | |
| 48 | - result.stderr.toString(), /--test-coverage cannot be used with --test/ | ||
| 49 | + result.stderr.toString(), | ||
| 50 | + /--experimental-test-coverage cannot be used with --test/ | ||
| 49 | 51 | ); | |
| 50 | 52 | }); | |
| 51 | 53 | ||
@@ -55,7 +57,7 @@ test('handles the inspector not being available', (t) => { | |||
| 55 | 57 | } | |
| 56 | 58 | ||
| 57 | 59 | const fixture = fixtures.path('test-runner', 'coverage.js'); | |
| 58 | - const args = ['--test-coverage', fixture]; | ||
| 60 | + const args = ['--experimental-test-coverage', fixture]; | ||
| 59 | 61 | const result = spawnSync(process.execPath, args); | |
| 60 | 62 | ||
| 61 | 63 | assert(!result.stdout.toString().includes('# start of coverage report')); | |
@@ -70,7 +72,7 @@ test('coverage is reported and dumped to NODE_V8_COVERAGE if present', (t) => { | |||
| 70 | 72 | } | |
| 71 | 73 | ||
| 72 | 74 | const fixture = fixtures.path('test-runner', 'coverage.js'); | |
| 73 | - const args = ['--test-coverage', fixture]; | ||
| 75 | + const args = ['--experimental-test-coverage', fixture]; | ||
| 74 | 76 | const options = { env: { ...process.env, NODE_V8_COVERAGE: tmpdir.path } }; | |
| 75 | 77 | const result = spawnSync(process.execPath, args, options); | |
| 76 | 78 | const report = getCoverageFixtureReport(); | |
@@ -87,7 +89,7 @@ test('coverage is reported without NODE_V8_COVERAGE present', (t) => { | |||
| 87 | 89 | } | |
| 88 | 90 | ||
| 89 | 91 | const fixture = fixtures.path('test-runner', 'coverage.js'); | |
| 90 | - const args = ['--test-coverage', fixture]; | ||
| 92 | + const args = ['--experimental-test-coverage', fixture]; | ||
| 91 | 93 | const result = spawnSync(process.execPath, args); | |
| 92 | 94 | const report = getCoverageFixtureReport(); | |
| 93 | 95 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments