Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: finish marking snapshot testing as stable #56425

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,13 @@

## Snapshot testing

cjihrig marked this conversation as resolved.
Show resolved Hide resolved
> Stability: 1.0 - Early development
<!-- YAML
added: v22.3.0
changes:
- version: v23.4.0
pr-url: https://github.com/nodejs/node/pull/55897

Check warning on line 939 in doc/api/test.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: Snapsnot testing is no longer experimental.
-->

Snapshot tests allow arbitrary values to be serialized into string values and
compared against a set of known good values. The known good values are known as
Expand Down Expand Up @@ -1750,8 +1756,6 @@
added: v22.3.0
-->

> Stability: 1.0 - Early development

An object whose methods are used to configure default snapshot settings in the
current process. It is possible to apply the same configuration to all files by
placing common configuration code in a module preloaded with `--require` or
Expand All @@ -1763,8 +1767,6 @@
added: v22.3.0
-->

> Stability: 1.0 - Early development

* `serializers` {Array} An array of synchronous functions used as the default
serializers for snapshot tests.

Expand All @@ -1780,8 +1782,6 @@
added: v22.3.0
-->

> Stability: 1.0 - Early development

* `fn` {Function} A function used to compute the location of the snapshot file.
The function receives the path of the test file as its only argument. If the
test is not associated with a file (for example in the REPL), the input is
Expand Down Expand Up @@ -3261,8 +3261,6 @@
added: v22.3.0
-->

> Stability: 1.0 - Early development

* `value` {any} A value to serialize to a string. If Node.js was started with
the [`--test-update-snapshots`][] flag, the serialized value is written to
the snapshot file. Otherwise, the serialized value is compared to the
Expand Down
6 changes: 1 addition & 5 deletions lib/internal/test_runner/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
ERR_INVALID_STATE,
},
} = require('internal/errors');
const { emitExperimentalWarning, kEmptyObject } = require('internal/util');
const { kEmptyObject } = require('internal/util');
let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => {
debug = fn;
});
Expand All @@ -28,7 +28,6 @@ const { strictEqual } = require('assert');
const { mkdirSync, readFileSync, writeFileSync } = require('fs');
const { dirname } = require('path');
const { createContext, runInContext } = require('vm');
const kExperimentalWarning = 'Snapshot testing';
const kMissingSnapshotTip = 'Missing snapshots can be generated by rerunning ' +
'the command with the --test-update-snapshots flag.';
const defaultSerializers = [
Expand All @@ -47,13 +46,11 @@ let resolveSnapshotPathFn = defaultResolveSnapshotPath;
let serializerFns = defaultSerializers;

function setResolveSnapshotPath(fn) {
emitExperimentalWarning(kExperimentalWarning);
validateFunction(fn, 'fn');
resolveSnapshotPathFn = fn;
}

function setDefaultSnapshotSerializers(serializers) {
emitExperimentalWarning(kExperimentalWarning);
validateFunctionArray(serializers, 'serializers');
serializerFns = ArrayPrototypeSlice(serializers);
}
Expand Down Expand Up @@ -207,7 +204,6 @@ class SnapshotManager {
const manager = this;

return function snapshotAssertion(actual, options = kEmptyObject) {
emitExperimentalWarning(kExperimentalWarning);
validateObject(options, 'options');
const {
serializers = serializerFns,
Expand Down
Loading