Files
vercel__next.js/test/babel.config.js
Sebastian "Sebbie" Silbermann 3c1f2d6aa9 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)
2024-12-10 02:41:17 +01:00

5 lines
152 B
JavaScript

// This config is only used for Jests's inline snapshot matcher.
module.exports = {
plugins: ['@babel/plugin-syntax-explicit-resource-management'],
}