Lines Matching +full:results +full:- +full:coverage
3 <!--introduced_in=v18.0.0-->
5 <!-- YAML
7 - v18.0.0
8 - v16.17.0
9 -->
11 > Stability: 1 - Experimental
13 <!-- source_link=lib/test.js -->
191 If Node.js is started with the [`--test-only`][] command-line option, it is
198 // Assume Node.js is run with the --test-only command-line option.
227 The [`--test-name-pattern`][] command-line option can be used to only run tests
229 JavaScript regular expressions. The `--test-name-pattern` option can be
235 `--test-name-pattern="test [1-3]"` option would cause the test runner to execute
238 same set of tests could also be executed by passing `--test-name-pattern`
239 multiple times (e.g. `--test-name-pattern="test 1"`,
240 `--test-name-pattern="test 2"`, etc.).
256 Node.js with `--test-name-pattern="/test [4-5]/i"` would match `Test 4` and
257 `Test 5` because the pattern is case-insensitive.
263 Once a test function finishes executing, the results are reported as quickly
267 reporting of test results in order to accommodate it.
272 results, the new subtest is immediately marked as failed, and reported later
298 <!-- YAML
300 -->
302 > Stability: 1 - Experimental
304 The Node.js test runner supports running in watch mode by passing the `--watch` flag:
307 node --test --watch
318 [`--test`][] flag:
321 node --test
334 node --test test1.js test2.mjs custom_test_dir/
358 * `^test$` - Files whose basename is the string `'test'`. Examples:
360 * `^test-.+` - Files whose basename starts with the string `'test-'`
361 followed by one or more characters. Examples: `test-example.js`,
362 `test-another-example.mjs`.
363 * `.+[\.\-\_]test$` - Files whose basename ends with `.test`, `-test`, or
365 `example-test.cjs`, `example_test.mjs`.
372 [`--test-concurrency`][] flag. If the child process finishes with an exit code
382 ## Collecting code coverage
384 When Node.js is started with the [`--experimental-test-coverage`][]
385 command-line flag, code coverage is collected and statistics are reported once
387 used to specify a code coverage directory, the generated V8 coverage files are
389 `node_modules/` directories are not included in the coverage report. If
390 coverage is enabled, the coverage report is sent to any [test reporters][] via
391 the `'test:coverage'` event.
393 Coverage can be disabled on a series of lines using the following
397 /* node:coverage disable */
400 // coverage purposes. All lines following the 'disable' comment are ignored
404 /* node:coverage enable */
407 Coverage can also be disabled for a specified number of lines. After the
408 specified number of lines, coverage will be automatically reenabled. If the
412 /* node:coverage ignore next */
415 /* node:coverage ignore next 3 */
421 The test runner's code coverage functionality has the following limitations,
425 * Excluding specific files or directories from the coverage report is not
430 The `node:test` module supports mocking during testing via a top-level `mock`
520 predictable tests for time-dependent functionality.
525 [node:timers/promises](./timers.md#timers-promises-api) modules,
623 <!-- YAML
626 - version: v18.17.0
627 pr-url: https://github.com/nodejs/node/pull/47238
629 -->
631 The `node:test` module supports passing [`--test-reporter`][]
634 The following built-reporters are supported:
637 The `tap` reporter outputs the test results in the [TAP][] format.
640 The `spec` reporter outputs the test results in a human-readable format.
643 The `dot` reporter outputs the test results in a compact format,
648 The junit reporter outputs test results in a jUnit XML format
665 [`--test-reporter`][] can be used to specify a path to custom reporter.
705 case 'test:coverage': {
750 case 'test:coverage': {
794 case 'test:coverage': {
834 case 'test:coverage': {
844 The value provided to `--test-reporter` should be a string like one used in an
849 The [`--test-reporter`][] flag can be specified multiple times to report test
850 results in several formats. In this situation
852 using [`--test-reporter-destination`][].
861 node --test-reporter=spec --test-reporter=dot --test-reporter-destination=stdout --test-reporter-de…
869 <!-- YAML
872 - version: v18.17.0
873 pr-url: https://github.com/nodejs/node/pull/47628
875 -->
882 If `true`, it would run `os.availableParallelism() - 1` test files in
898 * `signal` {AbortSignal} Allows aborting an in-progress test execution.
936 <!-- YAML
939 - version: v18.17.0
940 pr-url: https://github.com/nodejs/node/pull/47909
942 - version: v18.8.0
943 pr-url: https://github.com/nodejs/node/pull/43554
945 - version: v18.7.0
946 pr-url: https://github.com/nodejs/node/pull/43505
948 -->
951 results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn`
964 * `signal` {AbortSignal} Allows aborting an in-progress test.
966 provided, that string is displayed in the test results as the reason for
969 is provided, that string is displayed in the test results as the reason why
976 the callback function is passed as the second argument. **Default:** A no-op
982 invocation of this function results in reporting the test to the {TestsStream}.
1031 results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn`
1038 **Default:** A no-op function.
1042 invocation of this function results in the creation of a Subtest.
1057 <!-- YAML
1059 -->
1066 <!-- YAML
1068 - v18.6.0
1069 - v16.17.0
1071 - version: v18.16.0
1072 pr-url: https://github.com/nodejs/node/pull/46889
1074 -->
1092 <!-- YAML
1094 -->
1101 <!-- YAML
1103 -->
1107 the callback function is passed as the second argument. **Default:** A no-op
1111 * `signal` {AbortSignal} Allows aborting an in-progress hook.
1129 <!-- YAML
1131 -->
1135 the callback function is passed as the second argument. **Default:** A no-op
1139 * `signal` {AbortSignal} Allows aborting an in-progress hook.
1157 <!-- YAML
1159 -->
1163 the callback function is passed as the second argument. **Default:** A no-op
1167 * `signal` {AbortSignal} Allows aborting an in-progress hook.
1186 <!-- YAML
1188 -->
1192 the callback function is passed as the second argument. **Default:** A no-op
1196 * `signal` {AbortSignal} Allows aborting an in-progress hook.
1215 <!-- YAML
1217 -->
1224 <!-- YAML
1226 -->
1246 <!-- YAML
1248 -->
1258 <!-- YAML
1260 -->
1295 <!-- YAML
1297 -->
1339 <!-- YAML
1341 -->
1347 <!-- YAML
1349 -->
1356 <!-- YAML
1358 -->
1367 <!-- YAML
1369 -->
1372 **Default:** A no-op function.
1418 <!-- YAML
1420 -->
1427 <!-- YAML
1429 -->
1460 return this.value - a;
1481 <!-- YAML
1483 -->
1497 <!-- YAML
1499 -->
1507 <!-- YAML
1509 -->
1516 <!-- YAML
1518 - v18.19.0
1519 -->
1521 > Stability: 1 - Experimental
1527 The [`MockTracker`][] provides a top-level `timers` export
1532 <!-- YAML
1534 - v18.19.0
1535 -->
1563 [node:timers/promises](./timers.md#timers-promises-api), and
1575 <!-- YAML
1577 - v18.19.0
1578 -->
1603 <!-- YAML
1605 - v18.19.0
1606 -->
1747 [node:timers/promises](./timers.md#timers-promises-api) modules,
1808 In Node.js, `setInterval` from [node:timers/promises](./timers.md#timers-promises-api)
1838 assert.strictEqual(timeResults[it - 1], startedAt + (interval * it));
1870 assert.strictEqual(timeResults[it - 1], startedAt + (interval * it));
1877 <!-- YAML
1879 - v18.19.0
1880 -->
1893 const results = [];
1894 setTimeout(() => results.push(1), 9999);
1898 setTimeout(() => results.push(3), 8888);
1899 setTimeout(() => results.push(2), 8888);
1901 assert.deepStrictEqual(results, []);
1905 assert.deepStrictEqual(results, [3, 2, 1]);
1915 const results = [];
1916 setTimeout(() => results.push(1), 9999);
1920 setTimeout(() => results.push(3), 8888);
1921 setTimeout(() => results.push(2), 8888);
1923 assert.deepStrictEqual(results, []);
1927 assert.deepStrictEqual(results, [3, 2, 1]);
1933 It does not have any effect on real-time system
1938 <!-- YAML
1940 - v18.9.0
1941 - v16.19.0
1943 - version: v18.17.0
1944 pr-url: https://github.com/nodejs/node/pull/47094
1946 -->
1954 ### Event: `'test:coverage'`
1957 * `summary` {Object} An object containing the coverage report.
1958 * `files` {Array} An array of coverage reports for individual files. Each
1972 * `totals` {Object} An object containing a summary of coverage for all
1983 * `workingDirectory` {string} The working directory when code coverage
1988 Emitted when code coverage is enabled and all tests have completed.
2117 This event is only emitted if `--test` flag is passed.
2130 This event is only emitted if `--test` flag is passed.
2138 <!-- YAML
2141 - version: v18.17.0
2142 pr-url: https://github.com/nodejs/node/pull/47586
2144 -->
2152 <!-- YAML
2154 -->
2158 the callback function is passed as the second argument. **Default:** A no-op
2162 * `signal` {AbortSignal} Allows aborting an in-progress hook.
2172 <!-- YAML
2174 -->
2178 the callback function is passed as the second argument. **Default:** A no-op
2182 * `signal` {AbortSignal} Allows aborting an in-progress hook.
2204 <!-- YAML
2206 -->
2210 the callback function is passed as the second argument. **Default:** A no-op
2214 * `signal` {AbortSignal} Allows aborting an in-progress hook.
2231 <!-- YAML
2233 -->
2237 the callback function is passed as the second argument. **Default:** A no-op
2241 * `signal` {AbortSignal} Allows aborting an in-progress hook.
2263 <!-- YAML
2265 -->
2270 information is included at the end of the test's results. This function does
2281 <!-- YAML
2283 -->
2289 <!-- YAML
2291 -->
2297 started with the [`--test-only`][] command-line option, this function is a
2298 no-op.
2313 <!-- YAML
2315 -->
2328 <!-- YAML
2330 -->
2348 <!-- YAML
2350 -->
2367 <!-- YAML
2370 - version: v18.8.0
2371 pr-url: https://github.com/nodejs/node/pull/43554
2373 - version: v18.7.0
2374 pr-url: https://github.com/nodejs/node/pull/43505
2376 -->
2379 test results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if
2392 * `signal` {AbortSignal} Allows aborting an in-progress test.
2394 provided, that string is displayed in the test results as the reason for
2397 is provided, that string is displayed in the test results as the reason why
2404 the callback function is passed as the second argument. **Default:** A no-op
2425 <!-- YAML
2427 -->
2435 <!-- YAML
2437 -->
2443 <!-- YAML
2445 -->
2452 [`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
2453 [`--test-concurrency`]: cli.md#--test-concurrency
2454 [`--test-name-pattern`]: cli.md#--test-name-pattern
2455 [`--test-only`]: cli.md#--test-only
2456 [`--test-reporter-destination`]: cli.md#--test-reporter-destination
2457 [`--test-reporter`]: cli.md#--test-reporter
2458 [`--test`]: cli.md#--test
2459 [`MockFunctionContext`]: #class-mockfunctioncontext
2460 [`MockTimers`]: #class-mocktimers
2461 [`MockTracker.method`]: #mockmethodobject-methodname-implementation-options
2462 [`MockTracker`]: #class-mocktracker
2464 [`SuiteContext`]: #class-suitecontext
2465 [`TestContext`]: #class-testcontext
2469 [`describe()`]: #describename-options-fn
2471 [`test()`]: #testname-options-fn
2472 [describe options]: #describename-options-fn
2473 [it options]: #testname-options-fn
2475 [test reporters]: #test-reporters
2476 [test runner execution model]: #test-runner-execution-model