Skip to content

Commit a180e69

Browse files
authored
Proposal: Multiple Snapshot Formats
1 parent 54d0686 commit a180e69

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Support Multiple Snapshot Formats in the Node.js Test Runner
2+
3+
The current snapshot implementation in the Node.js Test Runner assumes a single snapshot file format (`.snapshot`).
4+
5+
However, Node.js itself natively supports multiple module and data formats:
6+
7+
* `.cjs` (CommonJS)
8+
* `.mjs` (ESM)
9+
* `.js` (Both)
10+
* `.json`
11+
12+
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.
13+
14+
## Goal
15+
16+
When resolving a snapshot file, the test runner should support multiple extensions.
17+
18+
Example resolution order:
19+
20+
```text
21+
<test>.snapshot.mjs
22+
<test>.snapshot.cjs
23+
<test>.snapshot.js
24+
<test>.snapshot.json
25+
```
26+
27+
Example error:
28+
29+
```
30+
Multiple snapshot files found for test "foo.test.js":
31+
- foo.test.snapshot.mjs
32+
- foo.test.snapshot.json
33+
```

0 commit comments

Comments
 (0)