diff --git a/proposals/multiple-snapshot-formats.md b/proposals/multiple-snapshot-formats.md new file mode 100644 index 0000000..73a0d15 --- /dev/null +++ b/proposals/multiple-snapshot-formats.md @@ -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 +.snapshot.mjs +.snapshot.cjs +.snapshot.js +.snapshot.json +``` + +Example error: + +``` +Multiple snapshot files found for test "foo.test.js": +- foo.test.snapshot.mjs +- foo.test.snapshot.json +```