Ensure inline snapshots can be updated in tests with `using` syntax (#73704)
Updates `jest-snapshot` to 30 to get Prettier v3 (v2 does not support `using` syntax) and configures Babel (`jest-snapshot` always uses Babel) to support `using` syntax via `@babel/plugin-proposal-explicit-resource-management`.
Could've gone with updating Jest entirely to Alpha but this seems more risky. Meanwhile, `jest-snapshot@30.0.0-alpha.6` seems to be backwards compatible with Jest 29. Their breaking change was only switching to Prettier v2.
## Test plan
With
```
diff --git a/test/development/acceptance-app/ReactRefreshLogBox.test.ts b/test/development/acceptance-app/ReactRefreshLogBox.test.ts
index e599b54aba..9617c9585b 100644
--- a/test/development/acceptance-app/ReactRefreshLogBox.test.ts
+++ b/test/development/acceptance-app/ReactRefreshLogBox.test.ts
@@ -1200,7 +1200,7 @@ export default function Home() {
`)
} else {
expect(source).toMatchInlineSnapshot(`
- "app/utils.ts (1:7) @ eval
+ "app/utils.ts (1:8) @ eval
> 1 | throw new Error('utils error')
| ^
```
```
$ pnpm
test-dev test/development/acceptance-app/ReactRefreshLogBox.test.ts -t "should collapse bundler internal stack frames"
● ReactRefreshLogBox app default › should collapse bundler internal stack frames
expect(received).toMatchInlineSnapshot(snapshot)
Snapshot name: `ReactRefreshLogBox app default should collapse bundler internal stack frames 1`
- Snapshot - 1
+ Received + 1
- app/utils.ts (1:8) @ eval
+ app/utils.ts (1:7) @ eval
> 1 | throw new Error('utils error')
| ^
2 | export function foo(){}
3 |
1200 | `)
1201 | } else {
> 1202 | expect(source).toMatchInlineSnapshot(`
| ^
1203 | "app/utils.ts (1:8) @ eval
1204 |
1205 | > 1 | throw new Error('utils error')
at Object.toMatchInlineSnapshot (development/acceptance-app/ReactRefreshLogBox.test.ts:1202:22)
› 1 snapshot failed
```
and `pnpm
test-dev test/development/acceptance-app/ReactRefreshLogBox.test.ts -t "should collapse bundler internal stack frames" -u` correctly updates (with some whitespace changes but that's a pretty common issue)
Showing
| ... | @@ -74,6 +74,7 @@ | ... | @@ -74,6 +74,7 @@ |
| "@babel/generator": "7.22.5", | "@babel/generator": "7.22.5", | ||
| "@babel/parser": "7.22.5", | "@babel/parser": "7.22.5", | ||
| "@babel/plugin-proposal-object-rest-spread": "7.20.7", | "@babel/plugin-proposal-object-rest-spread": "7.20.7", | ||
| "@babel/plugin-syntax-explicit-resource-management": "7.25.7", | |||
| "@babel/preset-flow": "7.22.5", | "@babel/preset-flow": "7.22.5", | ||
| "@babel/preset-react": "7.22.5", | "@babel/preset-react": "7.22.5", | ||
| "@edge-runtime/jest-environment": "4.0.0", | "@edge-runtime/jest-environment": "4.0.0", | ||
| ... | @@ -202,7 +203,6 @@ | ... | @@ -202,7 +203,6 @@ |
| "postcss-short-size": "4.0.0", | "postcss-short-size": "4.0.0", | ||
| "postcss-trolling": "0.1.7", | "postcss-trolling": "0.1.7", | ||
| "prettier": "3.2.5", | "prettier": "3.2.5", | ||
| "prettier-2": "npm:prettier@^2", | |||
| "pretty-bytes": "5.3.0", | "pretty-bytes": "5.3.0", | ||
| "pretty-ms": "7.0.0", | "pretty-ms": "7.0.0", | ||
| "random-seed": "0.3.0", | "random-seed": "0.3.0", | ||
| ... | @@ -267,6 +267,7 @@ | ... | @@ -267,6 +267,7 @@ |
| "@babel/traverse": "7.22.5", | "@babel/traverse": "7.22.5", | ||
| "@types/react": "19.0.0", | "@types/react": "19.0.0", | ||
| "@types/react-dom": "19.0.0", | "@types/react-dom": "19.0.0", | ||
| "jest-snapshot": "30.0.0-alpha.6", | |||
| "react": "19.0.0-rc-7283a213-20241206", | "react": "19.0.0-rc-7283a213-20241206", | ||
| "react-dom": "19.0.0-rc-7283a213-20241206", | "react-dom": "19.0.0-rc-7283a213-20241206", | ||
| "react-is": "19.0.0-rc-7283a213-20241206", | "react-is": "19.0.0-rc-7283a213-20241206", | ||
| ... | ... |
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
test/babel.config.js
0 → 100644
Please
register
or
sign in
to comment