Skip to content

Commit e0704b3

Browse files
committed
chore: add way to update snapshots
1 parent f35b64e commit e0704b3

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"check": "tsc --noEmit",
1515
"lint": "prettier --check .",
1616
"test": "vitest run",
17+
"test:update": "cross-env UPDATE_SNAPSHOT=true vitest run",
1718
"test:test262": "npm run build && node ./__test__/run_test262.js",
1819
"changeset:version": "changeset version && git add --all",
1920
"changeset:release": "changeset publish"
@@ -39,6 +40,7 @@
3940
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
4041
"acorn": "^8.14.0",
4142
"acorn-jsx": "~5.3.2",
43+
"cross-env": "^7.0.3",
4244
"esbuild": "^0.25.0",
4345
"prettier": "~3.5.2",
4446
"test262": "git+https://github.com/tc39/test262.git#88ebb1e3755198cd08757bca1698effbbf360345",

pnpm-lock.yaml

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/run.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ describe('tests', () => {
3030
? parseDtsSource(input_code)
3131
: parseSource(input_code);
3232

33-
equalNode(parsed_result, expected_result);
33+
try {
34+
equalNode(parsed_result, expected_result);
35+
} catch (e) {
36+
if (process.env.UPDATE_SNAPSHOT) {
37+
fs.writeFileSync(expected_path, JSON.stringify(parsed_result, null, 2));
38+
} else {
39+
throw e;
40+
}
41+
}
3442
});
3543
} else if (fs.existsSync(error_path)) {
3644
it(dirent.name, () => {

0 commit comments

Comments
 (0)