| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8a5d8c7 commit 8197815
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1135,16 +1135,6 @@ added: | |||
| 1135 | 1135 | ||
| 1136 | 1136 | Enable module mocking in the test runner. | |
| 1137 | 1137 | ||
| 1138 | - ### `--experimental-test-snapshots` | ||
| 1139 | - | ||
| 1140 | - <!-- YAML | ||
| 1141 | - added: v22.3.0 | ||
| 1142 | - --> | ||
| 1143 | - | ||
| 1144 | - > Stability: 1.0 - Early development | ||
| 1145 | - | ||
| 1146 | - Enable [snapshot testing][] in the test runner. | ||
| 1147 | - | ||
| 1148 | 1138 | ### `--experimental-vm-modules` | |
| 1149 | 1139 | ||
| 1150 | 1140 | <!-- YAML | |
@@ -2473,13 +2463,13 @@ subtests inherit this value from their parent. The default value is `Infinity`. | |||
| 2473 | 2463 | ||
| 2474 | 2464 | <!-- YAML | |
| 2475 | 2465 | added: v22.3.0 | |
| 2466 | + changes: | ||
| 2467 | + - version: REPLACEME | ||
| 2468 | + pr-url: https://github.com/nodejs/node/pull/55897 | ||
| 2469 | + description: Snapsnot testing is no longer experimental. | ||
| 2476 | 2470 | --> | |
| 2477 | 2471 | ||
| 2478 | - > Stability: 1.0 - Early development | ||
| 2479 | - | ||
| 2480 | 2472 | Regenerates the snapshot files used by the test runner for [snapshot testing][]. | |
| 2481 | - Node.js must be started with the `--experimental-test-snapshots` flag in order | ||
| 2482 | - to use this functionality. | ||
| 2483 | 2473 | ||
| 2484 | 2474 | ### `--throw-deprecation` | |
| 2485 | 2475 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -937,8 +937,7 @@ compared against a set of known good values. The known good values are known as | |||
| 937 | 937 | snapshots, and are stored in a snapshot file. Snapshot files are managed by the | |
| 938 | 938 | test runner, but are designed to be human readable to aid in debugging. Best | |
| 939 | 939 | practice is for snapshot files to be checked into source control along with your | |
| 940 | - test files. In order to enable snapshot testing, Node.js must be started with | ||
| 941 | - the [`--experimental-test-snapshots`][] command-line flag. | ||
| 940 | + test files. | ||
| 942 | 941 | ||
| 943 | 942 | Snapshot files are generated by starting Node.js with the | |
| 944 | 943 | [`--test-update-snapshots`][] command-line flag. A separate snapshot file is | |
@@ -3591,7 +3590,6 @@ Can be used to abort test subtasks when the test has been aborted. | |||
| 3591 | 3590 | [`--experimental-strip-types`]: cli.md#--experimental-strip-types | |
| 3592 | 3591 | [`--experimental-test-coverage`]: cli.md#--experimental-test-coverage | |
| 3593 | 3592 | [`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks | |
| 3594 | - [`--experimental-test-snapshots`]: cli.md#--experimental-test-snapshots | ||
| 3595 | 3593 | [`--import`]: cli.md#--importmodule | |
| 3596 | 3594 | [`--test-concurrency`]: cli.md#--test-concurrency | |
| 3597 | 3595 | [`--test-coverage-include`]: cli.md#--test-coverage-include | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,9 +191,6 @@ Configures the type of test isolation used in the test runner. | |||
| 191 | 191 | .It Fl -experimental-test-module-mocks | |
| 192 | 192 | Enable module mocking in the test runner. | |
| 193 | 193 | . | |
| 194 | - .It Fl -experimental-test-snapshots | ||
| 195 | - Enable snapshot testing in the test runner. | ||
| 196 | - . | ||
| 197 | 194 | .It Fl -experimental-strip-types | |
| 198 | 195 | Enable experimental type-stripping for TypeScript files. | |
| 199 | 196 | . | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,6 +104,7 @@ function lazyAssertObject(harness) { | |||
| 104 | 104 | if (assertObj === undefined) { | |
| 105 | 105 | assertObj = new SafeMap(); | |
| 106 | 106 | const assert = require('assert'); | |
| 107 | + const { SnapshotManager } = require('internal/test_runner/snapshot'); | ||
| 107 | 108 | const methodsToCopy = [ | |
| 108 | 109 | 'deepEqual', | |
| 109 | 110 | 'deepStrictEqual', | |
@@ -126,12 +127,8 @@ function lazyAssertObject(harness) { | |||
| 126 | 127 | assertObj.set(methodsToCopy[i], assert[methodsToCopy[i]]); | |
| 127 | 128 | } | |
| 128 | 129 | ||
| 129 | - const { getOptionValue } = require('internal/options'); | ||
| 130 | - if (getOptionValue('--experimental-test-snapshots')) { | ||
| 131 | - const { SnapshotManager } = require('internal/test_runner/snapshot'); | ||
| 132 | - harness.snapshotManager = new SnapshotManager(harness.config.updateSnapshots); | ||
| 133 | - assertObj.set('snapshot', harness.snapshotManager.createAssert()); | ||
| 134 | - } | ||
| 130 | + harness.snapshotManager = new SnapshotManager(harness.config.updateSnapshots); | ||
| 131 | + assertObj.set('snapshot', harness.snapshotManager.createAssert()); | ||
| 135 | 132 | } | |
| 136 | 133 | return assertObj; | |
| 137 | 134 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ const { | |||
| 7 | 7 | ||
| 8 | 8 | const { test, suite, before, after, beforeEach, afterEach } = require('internal/test_runner/harness'); | |
| 9 | 9 | const { run } = require('internal/test_runner/runner'); | |
| 10 | - const { getOptionValue } = require('internal/options'); | ||
| 11 | 10 | ||
| 12 | 11 | module.exports = test; | |
| 13 | 12 | ObjectAssign(module.exports, { | |
@@ -39,28 +38,26 @@ ObjectDefineProperty(module.exports, 'mock', { | |||
| 39 | 38 | }, | |
| 40 | 39 | }); | |
| 41 | 40 | ||
| 42 | - if (getOptionValue('--experimental-test-snapshots')) { | ||
| 43 | - let lazySnapshot; | ||
| 41 | + let lazySnapshot; | ||
| 44 | 42 | ||
| 45 | - ObjectDefineProperty(module.exports, 'snapshot', { | ||
| 46 | - __proto__: null, | ||
| 47 | - configurable: true, | ||
| 48 | - enumerable: true, | ||
| 49 | - get() { | ||
| 50 | - if (lazySnapshot === undefined) { | ||
| 51 | - const { | ||
| 52 | - setDefaultSnapshotSerializers, | ||
| 53 | - setResolveSnapshotPath, | ||
| 54 | - } = require('internal/test_runner/snapshot'); | ||
| 55 | - | ||
| 56 | - lazySnapshot = { | ||
| 57 | - __proto__: null, | ||
| 58 | - setDefaultSnapshotSerializers, | ||
| 59 | - setResolveSnapshotPath, | ||
| 60 | - }; | ||
| 61 | - } | ||
| 43 | + ObjectDefineProperty(module.exports, 'snapshot', { | ||
| 44 | + __proto__: null, | ||
| 45 | + configurable: true, | ||
| 46 | + enumerable: true, | ||
| 47 | + get() { | ||
| 48 | + if (lazySnapshot === undefined) { | ||
| 49 | + const { | ||
| 50 | + setDefaultSnapshotSerializers, | ||
| 51 | + setResolveSnapshotPath, | ||
| 52 | + } = require('internal/test_runner/snapshot'); | ||
| 53 | + | ||
| 54 | + lazySnapshot = { | ||
| 55 | + __proto__: null, | ||
| 56 | + setDefaultSnapshotSerializers, | ||
| 57 | + setResolveSnapshotPath, | ||
| 58 | + }; | ||
| 59 | + } | ||
| 62 | 60 | ||
| 63 | - return lazySnapshot; | ||
| 64 | - }, | ||
| 65 | - }); | ||
| 66 | - } | ||
| 61 | + return lazySnapshot; | ||
| 62 | + }, | ||
| 63 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -691,9 +691,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | |||
| 691 | 691 | AddOption("--experimental-test-module-mocks", | |
| 692 | 692 | "enable module mocking in the test runner", | |
| 693 | 693 | &EnvironmentOptions::test_runner_module_mocks); | |
| 694 | - AddOption("--experimental-test-snapshots", | ||
| 695 | - "enable snapshot testing in the test runner", | ||
| 696 | - &EnvironmentOptions::test_runner_snapshots); | ||
| 694 | + AddOption("--experimental-test-snapshots", "", NoOp{}); | ||
| 697 | 695 | AddOption("--test-name-pattern", | |
| 698 | 696 | "run tests whose name matches this regular expression", | |
| 699 | 697 | &EnvironmentOptions::test_name_pattern, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,7 +189,6 @@ class EnvironmentOptions : public Options { | |||
| 189 | 189 | uint64_t test_coverage_functions = 0; | |
| 190 | 190 | uint64_t test_coverage_lines = 0; | |
| 191 | 191 | bool test_runner_module_mocks = false; | |
| 192 | - bool test_runner_snapshots = false; | ||
| 193 | 192 | bool test_runner_update_snapshots = false; | |
| 194 | 193 | std::vector<std::string> test_name_pattern; | |
| 195 | 194 | std::vector<std::string> test_reporter; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,13 +3,14 @@ require('../common'); | |||
| 3 | 3 | const assert = require('node:assert'); | |
| 4 | 4 | const test = require('node:test'); | |
| 5 | 5 | ||
| 6 | - const uncopiedKeys = [ | ||
| 7 | - 'AssertionError', | ||
| 8 | - 'CallTracker', | ||
| 9 | - 'strict', | ||
| 10 | - ]; | ||
| 11 | - test('only methods from node:assert are on t.assert', (t) => { | ||
| 12 | - const expectedKeys = Object.keys(assert).filter((key) => !uncopiedKeys.includes(key)).sort(); | ||
| 6 | + test('expected methods are on t.assert', (t) => { | ||
| 7 | + const uncopiedKeys = [ | ||
| 8 | + 'AssertionError', | ||
| 9 | + 'CallTracker', | ||
| 10 | + 'strict', | ||
| 11 | + ]; | ||
| 12 | + const assertKeys = Object.keys(assert).filter((key) => !uncopiedKeys.includes(key)); | ||
| 13 | + const expectedKeys = ['snapshot'].concat(assertKeys).sort(); | ||
| 13 | 14 | assert.deepStrictEqual(Object.keys(t.assert).sort(), expectedKeys); | |
| 14 | 15 | }); | |
| 15 | 16 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - // Flags: --expose-internals --experimental-test-snapshots | ||
| 1 | + // Flags: --expose-internals | ||
| 2 | 2 | /* eslint-disable no-template-curly-in-string */ | |
| 3 | 3 | 'use strict'; | |
| 4 | 4 | const common = require('../common'); | |
@@ -299,7 +299,7 @@ test('t.assert.snapshot()', async (t) => { | |||
| 299 | 299 | await t.test('fails prior to snapshot generation', async (t) => { | |
| 300 | 300 | const child = await common.spawnPromisified( | |
| 301 | 301 | process.execPath, | |
| 302 | - ['--experimental-test-snapshots', fixture], | ||
| 302 | + [fixture], | ||
| 303 | 303 | { cwd: tmpdir.path }, | |
| 304 | 304 | ); | |
| 305 | 305 | ||
@@ -314,7 +314,7 @@ test('t.assert.snapshot()', async (t) => { | |||
| 314 | 314 | await t.test('passes when regenerating snapshots', async (t) => { | |
| 315 | 315 | const child = await common.spawnPromisified( | |
| 316 | 316 | process.execPath, | |
| 317 | - ['--test-update-snapshots', '--experimental-test-snapshots', fixture], | ||
| 317 | + ['--test-update-snapshots', fixture], | ||
| 318 | 318 | { cwd: tmpdir.path }, | |
| 319 | 319 | ); | |
| 320 | 320 | ||
@@ -328,7 +328,7 @@ test('t.assert.snapshot()', async (t) => { | |||
| 328 | 328 | await t.test('passes when snapshots exist', async (t) => { | |
| 329 | 329 | const child = await common.spawnPromisified( | |
| 330 | 330 | process.execPath, | |
| 331 | - ['--experimental-test-snapshots', fixture], | ||
| 331 | + [fixture], | ||
| 332 | 332 | { cwd: tmpdir.path }, | |
| 333 | 333 | ); | |
| 334 | 334 | ||
@@ -350,7 +350,6 @@ test('snapshots from multiple files (isolation=none)', async (t) => { | |||
| 350 | 350 | const args = [ | |
| 351 | 351 | '--test', | |
| 352 | 352 | '--experimental-test-isolation=none', | |
| 353 | - '--experimental-test-snapshots', | ||
| 354 | 353 | fixture, | |
| 355 | 354 | fixture2, | |
| 356 | 355 | ]; | |
@@ -372,7 +371,6 @@ test('snapshots from multiple files (isolation=none)', async (t) => { | |||
| 372 | 371 | const args = [ | |
| 373 | 372 | '--test', | |
| 374 | 373 | '--experimental-test-isolation=none', | |
| 375 | - '--experimental-test-snapshots', | ||
| 376 | 374 | '--test-update-snapshots', | |
| 377 | 375 | fixture, | |
| 378 | 376 | fixture2, | |
@@ -394,7 +392,6 @@ test('snapshots from multiple files (isolation=none)', async (t) => { | |||
| 394 | 392 | const args = [ | |
| 395 | 393 | '--test', | |
| 396 | 394 | '--experimental-test-isolation=none', | |
| 397 | - '--experimental-test-snapshots', | ||
| 398 | 395 | fixture, | |
| 399 | 396 | fixture2, | |
| 400 | 397 | ]; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments