Skip to content
Open
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
33 changes: 33 additions & 0 deletions proposals/multiple-snapshot-formats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Support Multiple Snapshot Formats in the Node.js Test Runner

The current snapshot implementation in the Node.js Test Runner assumes a single snapshot file format (`.snapshot`).

However, Node.js itself natively supports multiple module and data formats:

* `.cjs` (CommonJS)
* `.mjs` (ESM)
* `.js` (Both)
* `.json`

The test runner already embraces this flexibility for **test files themselves** (it automatically discovers `.js`, `.cjs`, and `.mjs` test files), so one would expect snapshots to be loadable the same way.

## Goal

When resolving a snapshot file, the test runner should support multiple extensions.

Example resolution order:

```text
<test>.snapshot.mjs
<test>.snapshot.cjs
<test>.snapshot.js
<test>.snapshot.json
```

Example error:

```
Multiple snapshot files found for test "foo.test.js":
- foo.test.snapshot.mjs
- foo.test.snapshot.json
```