Unverified Commit 3e88af42 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

test(snapshot): allow snapshot test not invalidate with --turbo (#43545)

parent f0c7e72c
......@@ -2,69 +2,73 @@ import { sandbox } from './helpers'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'
import { getSnapshotTestDescribe } from 'next-test-utils'
// TODO-APP: Investigate snapshot mismatch
describe('ReactRefreshLogBox app', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
'react-dom': 'latest',
},
skipStart: true,
for (const variant of ['default', 'turbo']) {
getSnapshotTestDescribe(variant)(`ReactRefreshLogBox app ${variant}`, () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: new FileRef(
path.join(__dirname, 'fixtures', 'default-template')
),
dependencies: {
react: 'latest',
'react-dom': 'latest',
},
skipStart: true,
})
})
})
afterAll(() => next.destroy())
// Module trace is only available with webpack 5
test('Node.js builtins', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'node_modules/my-package/index.js',
`
afterAll(() => next.destroy())
// Module trace is only available with webpack 5
test('Node.js builtins', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'node_modules/my-package/index.js',
`
const dns = require('dns')
module.exports = dns
`,
],
[
'node_modules/my-package/package.json',
`
],
[
'node_modules/my-package/package.json',
`
{
"name": "my-package",
"version": "0.0.1"
}
`,
],
])
)
],
])
)
await session.patch(
'index.js',
`
await session.patch(
'index.js',
`
import pkg from 'my-package'
export default function Hello() {
return (pkg ? <h1>Package loaded</h1> : <h1>Package did not load</h1>)
}
`
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
await cleanup()
})
await cleanup()
})
test('Module not found', async () => {
const { session, cleanup } = await sandbox(next)
test('Module not found', async () => {
const { session, cleanup } = await sandbox(next)
await session.patch(
'index.js',
`import Comp from 'b'
await session.patch(
'index.js',
`import Comp from 'b'
export default function Oops() {
return (
<div>
......@@ -73,22 +77,22 @@ describe('ReactRefreshLogBox app', () => {
)
}
`
)
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
await cleanup()
})
await cleanup()
})
test('Module not found empty import trace', async () => {
const { session, cleanup } = await sandbox(next)
test('Module not found empty import trace', async () => {
const { session, cleanup } = await sandbox(next)
await session.patch(
'app/page.js',
`'use client'
await session.patch(
'app/page.js',
`'use client'
import Comp from 'b'
export default function Oops() {
return (
......@@ -98,49 +102,50 @@ describe('ReactRefreshLogBox app', () => {
)
}
`
)
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
await cleanup()
})
await cleanup()
})
test('Module not found missing global CSS', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'app/page.js',
`'use client'
test('Module not found missing global CSS', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'app/page.js',
`'use client'
import './non-existent.css'
export default function Page(props) {
return <p>index page</p>
}
`,
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
await session.patch(
'app/page.js',
`'use client'
await session.patch(
'app/page.js',
`'use client'
export default function Page(props) {
return <p>index page</p>
}
`
)
expect(await session.hasRedbox(false)).toBe(false)
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')
)
expect(await session.hasRedbox(false)).toBe(false)
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')
await cleanup()
await cleanup()
})
})
})
}
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox app Module not found 1`] = `
exports[`ReactRefreshLogBox app default Module not found 1`] = `
"./index.js:1:0
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
......@@ -14,7 +14,7 @@ Import trace for requested module:
https://nextjs.org/docs/messages/module-not-found"
`;
exports[`ReactRefreshLogBox app Module not found empty import trace 1`] = `
exports[`ReactRefreshLogBox app default Module not found empty import trace 1`] = `
"./app/page.js:2:6
Module not found: Can't resolve 'b'
1 | 'use client'
......@@ -27,7 +27,7 @@ Module not found: Can't resolve 'b'
https://nextjs.org/docs/messages/module-not-found"
`;
exports[`ReactRefreshLogBox app Module not found missing global CSS 1`] = `
exports[`ReactRefreshLogBox app default Module not found missing global CSS 1`] = `
"./app/page.js:2:10
Module not found: Can't resolve './non-existent.css'
1 | 'use client'
......@@ -40,7 +40,7 @@ Module not found: Can't resolve './non-existent.css'
https://nextjs.org/docs/messages/module-not-found"
`;
exports[`ReactRefreshLogBox app Node.js builtins 1`] = `
exports[`ReactRefreshLogBox app default Node.js builtins 1`] = `
"./node_modules/my-package/index.js:2:0
Module not found: Can't resolve 'dns'
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox app Hydration errors should get error link 1`] = `
exports[`ReactRefreshLogBox app default Hydration errors should get error link 1`] = `
"Error: Text content does not match server-rendered HTML.
See more info here: https://nextjs.org/docs/messages/react-hydration-error"
`;
exports[`ReactRefreshLogBox app Should not show __webpack_exports__ when exporting anonymous arrow function 1`] = `
exports[`ReactRefreshLogBox app default Should not show __webpack_exports__ when exporting anonymous arrow function 1`] = `
"index.js (4:16) @ default
2 | export default () => {
......@@ -18,14 +18,14 @@ exports[`ReactRefreshLogBox app Should not show __webpack_exports__ when exporti
7 | return null"
`;
exports[`ReactRefreshLogBox app boundaries 1`] = `
exports[`ReactRefreshLogBox app default boundaries 1`] = `
"FunctionDefault.js (1:50) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^"
`;
exports[`ReactRefreshLogBox app conversion to class component (1) 1`] = `
exports[`ReactRefreshLogBox app default conversion to class component (1) 1`] = `
"Child.js (5:18) @ ClickCount.render
3 | export default class ClickCount extends Component {
......@@ -37,7 +37,7 @@ exports[`ReactRefreshLogBox app conversion to class component (1) 1`] = `
8 | "
`;
exports[`ReactRefreshLogBox app css syntax errors 1`] = `
exports[`ReactRefreshLogBox app default css syntax errors 1`] = `
"./index.module.css:1:1
Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id)
......@@ -45,23 +45,23 @@ Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at
| ^"
`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app logbox: anchors links in error messages 9`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 9`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox app logbox: can recover from a component error 1`] = `
exports[`ReactRefreshLogBox app default logbox: can recover from a component error 1`] = `
"child.js (4:16) @ Child
2 | // hello
......@@ -72,7 +72,7 @@ exports[`ReactRefreshLogBox app logbox: can recover from a component error 1`] =
6 | "
`;
exports[`ReactRefreshLogBox app logbox: can recover from a event handler error 1`] = `
exports[`ReactRefreshLogBox app default logbox: can recover from a event handler error 1`] = `
"index.js (8:18) @ eval
6 | const increment = useCallback(() => {
......@@ -84,7 +84,7 @@ exports[`ReactRefreshLogBox app logbox: can recover from a event handler error 1
11 | <main>"
`;
exports[`ReactRefreshLogBox app logbox: can recover from a syntax error without losing state 1`] = `
exports[`ReactRefreshLogBox app default logbox: can recover from a syntax error without losing state 1`] = `
"./index.js
Error:
x Unexpected eof
......@@ -101,7 +101,7 @@ Import trace for requested module:
./app/page.js"
`;
exports[`ReactRefreshLogBox app module init error not shown 1`] = `
exports[`ReactRefreshLogBox app default module init error not shown 1`] = `
"index.js (4:14) @ eval
2 | // top offset for snapshot
......@@ -113,7 +113,7 @@ exports[`ReactRefreshLogBox app module init error not shown 1`] = `
7 | return <h1>Default Export</h1>;"
`;
exports[`ReactRefreshLogBox app render error not shown right after syntax error 1`] = `
exports[`ReactRefreshLogBox app default render error not shown right after syntax error 1`] = `
"index.js (6:18) @ ClassDefault.render
4 | class ClassDefault extends React.Component {
......@@ -125,7 +125,7 @@ exports[`ReactRefreshLogBox app render error not shown right after syntax error
9 | }"
`;
exports[`ReactRefreshLogBox app should strip whitespace correctly with newline 1`] = `
exports[`ReactRefreshLogBox app default should strip whitespace correctly with newline 1`] = `
"index.js (9:34) @ onClick
7 |
......@@ -137,7 +137,7 @@ exports[`ReactRefreshLogBox app should strip whitespace correctly with newline 1
12 | </a>"
`;
exports[`ReactRefreshLogBox app stuck error 1`] = `
exports[`ReactRefreshLogBox app default stuck error 1`] = `
"Foo.js (4:10) @ Foo
2 | // intentionally skips export
......@@ -148,7 +148,7 @@ exports[`ReactRefreshLogBox app stuck error 1`] = `
6 | "
`;
exports[`ReactRefreshLogBox app syntax > runtime error 1`] = `
exports[`ReactRefreshLogBox app default syntax > runtime error 1`] = `
"index.js (6:16) @ Error
4 | setInterval(() => {
......@@ -160,7 +160,7 @@ exports[`ReactRefreshLogBox app syntax > runtime error 1`] = `
9 | return <div />"
`;
exports[`ReactRefreshLogBox app syntax > runtime error 2`] = `
exports[`ReactRefreshLogBox app default syntax > runtime error 2`] = `
"./index.js
Error:
x Expected '}', got '<eof>'
......@@ -182,7 +182,7 @@ Import trace for requested module:
./app/page.js"
`;
exports[`ReactRefreshLogBox app syntax > runtime error 3`] = `
exports[`ReactRefreshLogBox app default syntax > runtime error 3`] = `
"./index.js
Error:
x Expected '}', got '<eof>'
......@@ -204,7 +204,7 @@ Import trace for requested module:
./app/page.js"
`;
exports[`ReactRefreshLogBox app unterminated JSX 1`] = `
exports[`ReactRefreshLogBox app default unterminated JSX 1`] = `
"./index.js
Error:
x Unexpected token. Did you mean \`{'}'}\` or \`&rbrace;\`?
......
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { getSnapshotTestDescribe } from 'next-test-utils'
describe('ReactRefreshLogBox', () => {
let next: NextInstance
for (const variant of ['default', 'turbo']) {
getSnapshotTestDescribe(variant)(`ReactRefreshLogBox ${variant}`, () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {},
skipStart: true,
beforeAll(async () => {
next = await createNext({
files: {},
skipStart: true,
})
})
})
afterAll(() => next.destroy())
test('empty _app shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_app.js',
`
afterAll(() => next.destroy())
test('empty _app shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_app.js',
`
`,
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
`"Error: The default export is not a React Component in page: \\"/_app\\""`
)
await session.patch(
'pages/_app.js',
`
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
`"Error: The default export is not a React Component in page: \\"/_app\\""`
)
await session.patch(
'pages/_app.js',
`
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}
export default MyApp
`
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
})
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
})
test('empty _document shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_document.js',
`
test('empty _document shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_document.js',
`
`,
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
`"Error: The default export is not a React Component in page: \\"/_document\\""`
)
await session.patch(
'pages/_document.js',
`
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
`"Error: The default export is not a React Component in page: \\"/_document\\""`
)
await session.patch(
'pages/_document.js',
`
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
......@@ -86,49 +88,49 @@ describe('ReactRefreshLogBox', () => {
export default MyDocument
`
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
})
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
})
test('_app syntax error shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_app.js',
`
test('_app syntax error shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_app.js',
`
function MyApp({ Component, pageProps }) {
return <<Component {...pageProps} />;
}
export default MyApp
`,
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
await session.patch(
'pages/_app.js',
`
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
await session.patch(
'pages/_app.js',
`
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}
export default MyApp
`
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
})
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
})
test('_document syntax error shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_document.js',
`
test('_document syntax error shows logbox', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_document.js',
`
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {{
......@@ -152,15 +154,15 @@ describe('ReactRefreshLogBox', () => {
export default MyDocument
`,
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
await session.patch(
'pages/_document.js',
`
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
await session.patch(
'pages/_document.js',
`
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
......@@ -184,8 +186,9 @@ describe('ReactRefreshLogBox', () => {
export default MyDocument
`
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
)
expect(await session.hasRedbox()).toBe(false)
await cleanup()
})
})
})
}
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { getSnapshotTestDescribe } from 'next-test-utils'
describe('ReactRefreshLogBox', () => {
let next: NextInstance
for (const variant of ['default', 'turbo']) {
getSnapshotTestDescribe(variant)(`ReactRefreshLogBox ${variant}`, () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {},
skipStart: true,
beforeAll(async () => {
next = await createNext({
files: {},
skipStart: true,
})
})
})
afterAll(() => next.destroy())
// Module trace is only available with webpack 5
test('Node.js builtins', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'node_modules/my-package/index.js',
`
afterAll(() => next.destroy())
// Module trace is only available with webpack 5
test('Node.js builtins', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'node_modules/my-package/index.js',
`
const dns = require('dns')
module.exports = dns
`,
],
[
'node_modules/my-package/package.json',
`
],
[
'node_modules/my-package/package.json',
`
{
"name": "my-package",
"version": "0.0.1"
}
`,
],
])
)
],
])
)
await session.patch(
'index.js',
`
await session.patch(
'index.js',
`
import pkg from 'my-package'
export default function Hello() {
return (pkg ? <h1>Package loaded</h1> : <h1>Package did not load</h1>)
}
`
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
await cleanup()
})
await cleanup()
})
test('Module not found', async () => {
const { session, cleanup } = await sandbox(next)
test('Module not found', async () => {
const { session, cleanup } = await sandbox(next)
await session.patch(
'index.js',
`import Comp from 'b'
await session.patch(
'index.js',
`import Comp from 'b'
export default function Oops() {
return (
<div>
......@@ -67,22 +69,22 @@ describe('ReactRefreshLogBox', () => {
)
}
`
)
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
await cleanup()
})
await cleanup()
})
test('Module not found (empty import trace)', async () => {
const { session, cleanup } = await sandbox(next)
test('Module not found (empty import trace)', async () => {
const { session, cleanup } = await sandbox(next)
await session.patch(
'pages/index.js',
`import Comp from 'b'
await session.patch(
'pages/index.js',
`import Comp from 'b'
export default function Oops() {
return (
<div>
......@@ -91,58 +93,59 @@ describe('ReactRefreshLogBox', () => {
)
}
`
)
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
await cleanup()
})
await cleanup()
})
test('Module not found (missing global CSS)', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_app.js',
`
test('Module not found (missing global CSS)', async () => {
const { session, cleanup } = await sandbox(
next,
new Map([
[
'pages/_app.js',
`
import './non-existent.css'
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
}
`,
],
[
'pages/index.js',
`
],
[
'pages/index.js',
`
export default function Page(props) {
return <p>index page</p>
}
`,
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
],
])
)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
await session.patch(
'pages/_app.js',
`
await session.patch(
'pages/_app.js',
`
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
}
`
)
expect(await session.hasRedbox(false)).toBe(false)
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')
)
expect(await session.hasRedbox(false)).toBe(false)
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')
await cleanup()
await cleanup()
})
})
})
}
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox _app syntax error shows logbox 1`] = `
exports[`ReactRefreshLogBox default _app syntax error shows logbox 1`] = `
"./pages/_app.js
Error:
x Expression expected
......@@ -30,7 +30,7 @@ Caused by:
1: Syntax Error"
`;
exports[`ReactRefreshLogBox _document syntax error shows logbox 1`] = `
exports[`ReactRefreshLogBox default _document syntax error shows logbox 1`] = `
"./pages/_document.js
Error:
x Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox Module not found (empty import trace) 1`] = `
exports[`ReactRefreshLogBox default Module not found (empty import trace) 1`] = `
"./pages/index.js:1:0
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
......@@ -11,20 +11,20 @@ Module not found: Can't resolve 'b'
https://nextjs.org/docs/messages/module-not-found"
`;
exports[`ReactRefreshLogBox Module not found (missing global CSS) 1`] = `
exports[`ReactRefreshLogBox default Module not found (missing global CSS) 1`] = `
"./pages/_app.js:2:8
Module not found: Can't resolve './non-existent.css'
1 |
> 2 | import './non-existent.css'
| ^
3 |
3 |
4 | export default function App({ Component, pageProps }) {
5 | return <Component {...pageProps} />
https://nextjs.org/docs/messages/module-not-found"
`;
exports[`ReactRefreshLogBox Module not found 1`] = `
exports[`ReactRefreshLogBox default Module not found 1`] = `
"./index.js:1:0
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
......@@ -38,7 +38,7 @@ Import trace for requested module:
https://nextjs.org/docs/messages/module-not-found"
`;
exports[`ReactRefreshLogBox Node.js builtins 1`] = `
exports[`ReactRefreshLogBox default Node.js builtins 1`] = `
"./node_modules/my-package/index.js:2:0
Module not found: Can't resolve 'dns'
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox boundaries 1`] = `
exports[`ReactRefreshLogBox default boundaries 1`] = `
"FunctionDefault.js (1:50) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^"
`;
exports[`ReactRefreshLogBox conversion to class component (1) 1`] = `
exports[`ReactRefreshLogBox default conversion to class component (1) 1`] = `
"Child.js (5:18) @ ClickCount.render
3 | export default class ClickCount extends Component {
......@@ -19,7 +19,7 @@ exports[`ReactRefreshLogBox conversion to class component (1) 1`] = `
8 | "
`;
exports[`ReactRefreshLogBox css syntax errors 1`] = `
exports[`ReactRefreshLogBox default css syntax errors 1`] = `
"./index.module.css:1:1
Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id)
......@@ -27,23 +27,23 @@ Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at
| ^"
`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox logbox: anchors links in error messages 9`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 9`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox logbox: can recover from a component error 1`] = `
exports[`ReactRefreshLogBox default logbox: can recover from a component error 1`] = `
"child.js (4:16) @ Child
2 | // hello
......@@ -54,7 +54,7 @@ exports[`ReactRefreshLogBox logbox: can recover from a component error 1`] = `
6 | "
`;
exports[`ReactRefreshLogBox logbox: can recover from a event handler error 1`] = `
exports[`ReactRefreshLogBox default logbox: can recover from a event handler error 1`] = `
"index.js (8:18) @ eval
6 | const increment = useCallback(() => {
......@@ -66,7 +66,7 @@ exports[`ReactRefreshLogBox logbox: can recover from a event handler error 1`] =
11 | <main>"
`;
exports[`ReactRefreshLogBox logbox: can recover from a syntax error without losing state 1`] = `
exports[`ReactRefreshLogBox default logbox: can recover from a syntax error without losing state 1`] = `
"./index.js
Error:
x Unexpected eof
......@@ -82,7 +82,7 @@ Import trace for requested module:
./index.js"
`;
exports[`ReactRefreshLogBox module init error not shown 1`] = `
exports[`ReactRefreshLogBox default module init error not shown 1`] = `
"index.js (4:14) @ eval
2 | // top offset for snapshot
......@@ -94,7 +94,7 @@ exports[`ReactRefreshLogBox module init error not shown 1`] = `
7 | return <h1>Default Export</h1>;"
`;
exports[`ReactRefreshLogBox render error not shown right after syntax error 1`] = `
exports[`ReactRefreshLogBox default render error not shown right after syntax error 1`] = `
"index.js (6:18) @ ClassDefault.render
4 | class ClassDefault extends React.Component {
......@@ -106,7 +106,7 @@ exports[`ReactRefreshLogBox render error not shown right after syntax error 1`]
9 | }"
`;
exports[`ReactRefreshLogBox should strip whitespace correctly with newline 1`] = `
exports[`ReactRefreshLogBox default should strip whitespace correctly with newline 1`] = `
"index.js (9:34) @ onClick
7 |
......@@ -118,7 +118,7 @@ exports[`ReactRefreshLogBox should strip whitespace correctly with newline 1`] =
12 | </a>"
`;
exports[`ReactRefreshLogBox stuck error 1`] = `
exports[`ReactRefreshLogBox default stuck error 1`] = `
"Foo.js (4:10) @ Foo
2 | // intentionally skips export
......@@ -129,7 +129,7 @@ exports[`ReactRefreshLogBox stuck error 1`] = `
6 | "
`;
exports[`ReactRefreshLogBox syntax > runtime error 1`] = `
exports[`ReactRefreshLogBox default syntax > runtime error 1`] = `
"index.js (6:16) @ Error
4 | setInterval(() => {
......@@ -141,7 +141,7 @@ exports[`ReactRefreshLogBox syntax > runtime error 1`] = `
9 | return <div />"
`;
exports[`ReactRefreshLogBox syntax > runtime error 2`] = `
exports[`ReactRefreshLogBox default syntax > runtime error 2`] = `
"./index.js
Error:
x Expected '}', got '<eof>'
......@@ -162,7 +162,7 @@ Import trace for requested module:
./index.js"
`;
exports[`ReactRefreshLogBox syntax > runtime error 3`] = `
exports[`ReactRefreshLogBox default syntax > runtime error 3`] = `
"./index.js
Error:
x Expected '}', got '<eof>'
......@@ -183,7 +183,7 @@ Import trace for requested module:
./index.js"
`;
exports[`ReactRefreshLogBox unterminated JSX 1`] = `
exports[`ReactRefreshLogBox default unterminated JSX 1`] = `
"./index.js
Error:
x Unexpected token. Did you mean \`{'}'}\` or \`&rbrace;\`?
......
......@@ -940,3 +940,20 @@ export function shouldRunTurboDevTest() {
// If the test path matches the glob pattern, add additional case to run the test with `--turbo` flag.
return isMatch
}
// WEB-168: There are some differences / incompletes in turbopack implementation enforces jest requires to update
// test snapshot when run against turbo. This fn returns describe, or describe.skip dependes on the running context
// to avoid force-snapshot update per each runs until turbopack update includes all the changes.
export function getSnapshotTestDescribe(variant) {
const runningEnv = variant ?? 'default'
if (runningEnv !== 'default' && runningEnv !== 'turbo') {
throw new Error(`Check if test env passed correctly ${variant}`)
}
const shouldRunTurboDev = shouldRunTurboDevTest()
const shouldSkip =
(runningEnv === 'turbo' && !shouldRunTurboDev) ||
(runningEnv === 'default' && shouldRunTurboDev)
return shouldSkip ? describe.skip : describe
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment