+
+ Import trace for requested module:
+ ./pages/index.js
+
+ https://nextjs.org/docs/messages/module-not-found"
+ `)
+ }
await cleanup()
})
@@ -96,7 +126,20 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
- expect(source).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(source).toMatchSnapshot()
+ } else {
+ expect(source).toMatchInlineSnapshot(`
+ "./pages/index.js:1:0
+ Module not found: Can't resolve 'b'
+ > 1 | import Comp from 'b'
+ 2 | export default function Oops() {
+ 3 | return (
+ 4 |
+
+ https://nextjs.org/docs/messages/module-not-found"
+ `)
+ }
await cleanup()
})
@@ -109,7 +152,7 @@ describe('ReactRefreshLogBox', () => {
'pages/_app.js',
`
import './non-existent.css'
-
+
export default function App({ Component, pageProps }) {
return
}
@@ -128,7 +171,22 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
- expect(source).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(source).toMatchSnapshot()
+ } else {
+ expect(source).toMatchInlineSnapshot(`
+ "./pages/_app.js:2:8
+ Module not found: Can't resolve './non-existent.css'
+ 1 |
+ > 2 | import './non-existent.css'
+ | ^
+ 3 |
+ 4 | export default function App({ Component, pageProps }) {
+ 5 | return
+
+ https://nextjs.org/docs/messages/module-not-found"
+ `)
+ }
await session.patch(
'pages/_app.js',
diff --git a/test/development/acceptance/ReactRefreshLogBox-scss.test.ts b/test/development/acceptance/ReactRefreshLogBox-scss.test.ts
index 93fcaf5cba6d1..91fad5b7d9211 100644
--- a/test/development/acceptance/ReactRefreshLogBox-scss.test.ts
+++ b/test/development/acceptance/ReactRefreshLogBox-scss.test.ts
@@ -2,6 +2,7 @@
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
+import { shouldRunTurboDevTest } from 'next-test-utils'
// TODO: figure out why snapshots mismatch on GitHub actions
// specifically but work in docker and locally
@@ -43,13 +44,21 @@ describe.skip('ReactRefreshLogBox', () => {
await session.patch('index.module.scss', `.button { font-size: :5px; }`)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
- expect(source).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(source).toMatchSnapshot()
+ } else {
+ expect(source).toMatchInlineSnapshot()
+ }
// Not local error
await session.patch('index.module.scss', `button { font-size: 5px; }`)
expect(await session.hasRedbox(true)).toBe(true)
const source2 = await session.getRedboxSource()
- expect(source2).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(source2).toMatchSnapshot()
+ } else {
+ expect(source2).toMatchInlineSnapshot()
+ }
await cleanup()
})
diff --git a/test/development/acceptance/ReactRefreshLogBox.test.ts b/test/development/acceptance/ReactRefreshLogBox.test.ts
index d9aced58dba6f..c6704bbbd38ad 100644
--- a/test/development/acceptance/ReactRefreshLogBox.test.ts
+++ b/test/development/acceptance/ReactRefreshLogBox.test.ts
@@ -2,7 +2,7 @@
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
-import { check } from 'next-test-utils'
+import { check, shouldRunTurboDevTest } from 'next-test-utils'
describe('ReactRefreshLogBox', () => {
let next: NextInstance
@@ -24,7 +24,7 @@ describe('ReactRefreshLogBox', () => {
export default function Page() {
return (
<>
-
+
index page
{
@@ -40,7 +40,21 @@ describe('ReactRefreshLogBox', () => {
await session.evaluate(() => document.querySelector('a').click())
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "index.js (9:34) @ onClick
+
+ 7 |
+ 8 | {
+ > 9 | throw new Error('idk')
+ | ^
+ 10 | }}>
+ 11 | click me
+ 12 | "
+ `)
+ }
await cleanup()
})
@@ -74,7 +88,22 @@ describe('ReactRefreshLogBox', () => {
await session.patch('index.js', `export default () =>
{
expect(await session.hasRedbox(true)).toBe(true)
if (process.platform === 'win32') {
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot()
+ }
} else {
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "index.js (8:18) @ eval
+
+ 6 | const increment = useCallback(() => {
+ 7 | setCount(c => c + 1)
+ > 8 | throw new Error('oops')
+ | ^
+ 9 | }, [setCount])
+ 10 | return (
+ 11 |
"
+ `)
+ }
}
await session.patch(
@@ -218,7 +265,20 @@ describe('ReactRefreshLogBox', () => {
)
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "child.js (4:16) @ Child
+
+ 2 | // hello
+ 3 | export default function Child() {
+ > 4 | throw new Error('oops')
+ | ^
+ 5 | }
+ 6 | "
+ `)
+ }
const didNotReload = await session.patch(
'child.js',
@@ -313,7 +373,21 @@ describe('ReactRefreshLogBox', () => {
`
)
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "index.js (6:18) @ ClassDefault.render
+
+ 4 | class ClassDefault extends React.Component {
+ 5 | render() {
+ > 6 | throw new Error('nooo');
+ | ^
+ 7 | return Default Export
;
+ 8 | }
+ 9 | }"
+ `)
+ }
await cleanup()
})
@@ -358,7 +432,21 @@ describe('ReactRefreshLogBox', () => {
)
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "index.js (4:14) @ eval
+
+ 2 | // top offset for snapshot
+ 3 | import * as React from 'react';
+ > 4 | throw new Error('no')
+ | ^
+ 5 | class ClassDefault extends React.Component {
+ 6 | render() {
+ 7 | return Default Export
;"
+ `)
+ }
await cleanup()
})
@@ -407,7 +495,20 @@ describe('ReactRefreshLogBox', () => {
// We get an error because Foo didn't import React. Fair.
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "Foo.js (4:10) @ Foo
+
+ 2 | // intentionally skips export
+ 3 | export default function Foo() {
+ > 4 | return React.createElement('h1', null, 'Foo');
+ | ^
+ 5 | }
+ 6 | "
+ `)
+ }
// Let's add that to Foo.
await session.patch(
@@ -460,9 +561,27 @@ describe('ReactRefreshLogBox', () => {
await new Promise((resolve) => setTimeout(resolve, 1000))
expect(await session.hasRedbox(true)).toBe(true)
if (process.platform === 'win32') {
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot()
+ }
} else {
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "index.js (6:16) @ Error
+
+ 4 | setInterval(() => {
+ 5 | i++
+ > 6 | throw Error('no ' + i)
+ | ^
+ 7 | }, 1000)
+ 8 | export default function FunctionNamed() {
+ 9 | return "
+ `)
+ }
}
// Make a syntax error.
@@ -480,12 +599,46 @@ describe('ReactRefreshLogBox', () => {
await new Promise((resolve) => setTimeout(resolve, 1000))
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "./index.js
+ Error:
+ x Expected '}', got ''
+ ,----
+ 8 | export default function FunctionNamed() {
+ : ^
+ \`----
+
+ Caused by:
+ 0: failed to process input file
+ 1: error was recoverable, but proceeding would result in wrong codegen
+ 2: Syntax Error"
+ `)
+ }
// Test that runtime error does not take over:
await new Promise((resolve) => setTimeout(resolve, 2000))
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "./index.js
+ Error:
+ x Expected '}', got ''
+ ,----
+ 8 | export default function FunctionNamed() {
+ : ^
+ \`----
+
+ Caused by:
+ 0: failed to process input file
+ 1: error was recoverable, but proceeding would result in wrong codegen
+ 2: Syntax Error"
+ `)
+ }
await cleanup()
})
@@ -546,7 +699,16 @@ describe('ReactRefreshLogBox', () => {
)
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "FunctionDefault.js (1:50) @ FunctionDefault
+
+ > 1 | export default function FunctionDefault() { throw new Error('no'); }
+ | ^"
+ `)
+ }
expect(
await session.evaluate(() => document.querySelector('h2').textContent)
).toBe('error')
@@ -614,7 +776,29 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
- expect(source).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(source).toMatchSnapshot()
+ } else {
+ expect(source).toMatchInlineSnapshot(`
+ "./index.js
+ Error:
+ x Unexpected token. Did you mean \`{'}'}\` or \`}\`?
+ ,----
+ 8 | }
+ : ^
+ \`----
+
+ x Unexpected eof
+ ,----
+ 9 |
+ : ^
+ \`----
+
+ Caused by:
+ 0: failed to process input file
+ 1: Syntax Error"
+ `)
+ }
await cleanup()
})
@@ -665,7 +849,21 @@ describe('ReactRefreshLogBox', () => {
)
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxSource()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxSource()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
+ "Child.js (5:18) @ ClickCount.render
+
+ 3 | export default class ClickCount extends Component {
+ 4 | render() {
+ > 5 | throw new Error()
+ | ^
+ 6 | }
+ 7 | }
+ 8 | "
+ `)
+ }
await session.patch(
'Child.js',
@@ -721,7 +919,17 @@ describe('ReactRefreshLogBox', () => {
await session.patch('index.module.css', `button {}`)
expect(await session.hasRedbox(true)).toBe(true)
const source2 = await session.getRedboxSource()
- expect(source2).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(source2).toMatchSnapshot()
+ } else {
+ expect(source2).toMatchInlineSnapshot(`
+ "./index.module.css:1:1
+ Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id)
+
+ > 1 | button {}
+ | ^"
+ `)
+ }
await cleanup()
})
@@ -752,7 +960,11 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)
const header = await session.getRedboxDescription()
- expect(header).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(header).toMatchSnapshot()
+ } else {
+ expect(header).toMatchInlineSnapshot(`"Error: end http://nextjs.org"`)
+ }
expect(
await session.evaluate(
() =>
@@ -762,18 +974,24 @@ describe('ReactRefreshLogBox', () => {
.length
)
).toBe(1)
- expect(
- await session.evaluate(
- () =>
- (
- document
- .querySelector('body > nextjs-portal')
- .shadowRoot.querySelector(
- '#nextjs__container_errors_desc a:nth-of-type(1)'
- ) as any
- ).href
+ const nextJsPortalErrorValue = await session.evaluate(
+ () =>
+ (
+ document
+ .querySelector('body > nextjs-portal')
+ .shadowRoot.querySelector(
+ '#nextjs__container_errors_desc a:nth-of-type(1)'
+ ) as any
+ ).href
+ )
+
+ if (!shouldRunTurboDevTest()) {
+ expect(nextJsPortalErrorValue).toMatchSnapshot()
+ } else {
+ expect(nextJsPortalErrorValue).toMatchInlineSnapshot(
+ `"http://nextjs.org/"`
)
- ).toMatchSnapshot()
+ }
await session.patch(
'index.js',
@@ -798,7 +1016,11 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)
const header2 = await session.getRedboxDescription()
- expect(header2).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(header2).toMatchSnapshot()
+ } else {
+ expect(header2).toMatchInlineSnapshot(`"Error: http://nextjs.org start"`)
+ }
expect(
await session.evaluate(
() =>
@@ -808,18 +1030,24 @@ describe('ReactRefreshLogBox', () => {
.length
)
).toBe(1)
- expect(
- await session.evaluate(
- () =>
- (
- document
- .querySelector('body > nextjs-portal')
- .shadowRoot.querySelector(
- '#nextjs__container_errors_desc a:nth-of-type(1)'
- ) as any
- ).href
+ const nextJsPortalContainerErrorsValue = await session.evaluate(
+ () =>
+ (
+ document
+ .querySelector('body > nextjs-portal')
+ .shadowRoot.querySelector(
+ '#nextjs__container_errors_desc a:nth-of-type(1)'
+ ) as any
+ ).href
+ )
+
+ if (!shouldRunTurboDevTest()) {
+ expect(nextJsPortalContainerErrorsValue).toMatchSnapshot()
+ } else {
+ expect(nextJsPortalContainerErrorsValue).toMatchInlineSnapshot(
+ `"http://nextjs.org/"`
)
- ).toMatchSnapshot()
+ }
await session.patch(
'index.js',
@@ -844,7 +1072,13 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)
const header3 = await session.getRedboxDescription()
- expect(header3).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(header3).toMatchSnapshot()
+ } else {
+ expect(header3).toMatchInlineSnapshot(
+ `"Error: middle http://nextjs.org end"`
+ )
+ }
expect(
await session.evaluate(
() =>
@@ -854,18 +1088,24 @@ describe('ReactRefreshLogBox', () => {
.length
)
).toBe(1)
- expect(
- await session.evaluate(
- () =>
- (
- document
- .querySelector('body > nextjs-portal')
- .shadowRoot.querySelector(
- '#nextjs__container_errors_desc a:nth-of-type(1)'
- ) as any
- ).href
+ const nextJsPortalContainerErrorsValue2 = await session.evaluate(
+ () =>
+ (
+ document
+ .querySelector('body > nextjs-portal')
+ .shadowRoot.querySelector(
+ '#nextjs__container_errors_desc a:nth-of-type(1)'
+ ) as any
+ ).href
+ )
+
+ if (!shouldRunTurboDevTest()) {
+ expect(nextJsPortalContainerErrorsValue2).toMatchSnapshot()
+ } else {
+ expect(nextJsPortalContainerErrorsValue2).toMatchInlineSnapshot(
+ `"http://nextjs.org/"`
)
- ).toMatchSnapshot()
+ }
await session.patch(
'index.js',
@@ -902,30 +1142,39 @@ describe('ReactRefreshLogBox', () => {
.length
)
).toBe(2)
- expect(
- await session.evaluate(
- () =>
- (
- document
- .querySelector('body > nextjs-portal')
- .shadowRoot.querySelector(
- '#nextjs__container_errors_desc a:nth-of-type(1)'
- ) as any
- ).href
+
+ const nextJsPortalContainerErrorsValue3 = await session.evaluate(
+ () =>
+ (
+ document
+ .querySelector('body > nextjs-portal')
+ .shadowRoot.querySelector(
+ '#nextjs__container_errors_desc a:nth-of-type(1)'
+ ) as any
+ ).href
+ )
+ const nextJsPortalContainerErrorsValue4 = await session.evaluate(
+ () =>
+ (
+ document
+ .querySelector('body > nextjs-portal')
+ .shadowRoot.querySelector(
+ '#nextjs__container_errors_desc a:nth-of-type(2)'
+ ) as any
+ ).href
+ )
+
+ if (!shouldRunTurboDevTest()) {
+ expect(nextJsPortalContainerErrorsValue3).toMatchSnapshot()
+ expect(nextJsPortalContainerErrorsValue4).toMatchSnapshot()
+ } else {
+ expect(nextJsPortalContainerErrorsValue3).toMatchInlineSnapshot(
+ `"http://nextjs.org/"`
)
- ).toMatchSnapshot()
- expect(
- await session.evaluate(
- () =>
- (
- document
- .querySelector('body > nextjs-portal')
- .shadowRoot.querySelector(
- '#nextjs__container_errors_desc a:nth-of-type(2)'
- ) as any
- ).href
+ expect(nextJsPortalContainerErrorsValue4).toMatchInlineSnapshot(
+ `"http://example.com/"`
)
- ).toMatchSnapshot()
+ }
await cleanup()
})
@@ -966,7 +1215,7 @@ describe('ReactRefreshLogBox', () => {
'index.js',
`
class Hello {}
-
+
export default () => {
throw Hello
return (
diff --git a/test/development/acceptance/ReactRefreshLogBoxMisc.test.ts b/test/development/acceptance/ReactRefreshLogBoxMisc.test.ts
index 738e7a5f79b92..81f998b0740f2 100644
--- a/test/development/acceptance/ReactRefreshLogBoxMisc.test.ts
+++ b/test/development/acceptance/ReactRefreshLogBoxMisc.test.ts
@@ -1,6 +1,7 @@
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
+import { shouldRunTurboDevTest } from 'next-test-utils'
// TODO: re-enable these tests after figuring out what is causing
// them to be so unreliable in CI
@@ -180,7 +181,11 @@ describe.skip('ReactRefreshLogBox', () => {
`
)
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxDescription()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxDescription()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxDescription()).toMatchInlineSnapshot()
+ }
await session.patch(
'index.js',
@@ -205,7 +210,11 @@ describe.skip('ReactRefreshLogBox', () => {
`
)
expect(await session.hasRedbox(true)).toBe(true)
- expect(await session.getRedboxDescription()).toMatchSnapshot()
+ if (!shouldRunTurboDevTest()) {
+ expect(await session.getRedboxDescription()).toMatchSnapshot()
+ } else {
+ expect(await session.getRedboxDescription()).toMatchInlineSnapshot()
+ }
await cleanup()
})