Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
3e88af42
Unverified
Commit
3e88af42
authored
Jan 13, 2023
by
OJ Kwon
Committed by
GitHub
Jan 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(snapshot): allow snapshot test not invalidate with --turbo (#43545)
parent
f0c7e72c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1614 additions
and
1576 deletions
+1614
-1576
ReactRefreshLogBox-builtins.test.ts
...opment/acceptance-app/ReactRefreshLogBox-builtins.test.ts
+87
-82
ReactRefreshLogBox.test.ts
test/development/acceptance-app/ReactRefreshLogBox.test.ts
+726
-718
ReactRefreshLogBox-builtins.test.ts.snap
...pp/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap
+4
-4
ReactRefreshLogBox.test.ts.snap
...eptance-app/__snapshots__/ReactRefreshLogBox.test.ts.snap
+24
-24
ReactRefreshLogBox-app-doc.test.ts
...development/acceptance/ReactRefreshLogBox-app-doc.test.ts
+98
-95
ReactRefreshLogBox-builtins.test.ts
...evelopment/acceptance/ReactRefreshLogBox-builtins.test.ts
+85
-82
ReactRefreshLogBox.test.ts
test/development/acceptance/ReactRefreshLogBox.test.ts
+544
-542
ReactRefreshLogBox-app-doc.test.ts.snap
...nce/__snapshots__/ReactRefreshLogBox-app-doc.test.ts.snap
+2
-2
ReactRefreshLogBox-builtins.test.ts.snap
...ce/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap
+5
-5
ReactRefreshLogBox.test.ts.snap
.../acceptance/__snapshots__/ReactRefreshLogBox.test.ts.snap
+22
-22
next-test-utils.js
test/lib/next-test-utils.js
+17
-0
No files found.
test/development/acceptance-app/ReactRefreshLogBox-builtins.test.ts
View file @
3e88af42
...
@@ -2,69 +2,73 @@ import { sandbox } from './helpers'
...
@@ -2,69 +2,73 @@ import { sandbox } from './helpers'
import
{
createNext
,
FileRef
}
from
'e2e-utils'
import
{
createNext
,
FileRef
}
from
'e2e-utils'
import
{
NextInstance
}
from
'test/lib/next-modes/base'
import
{
NextInstance
}
from
'test/lib/next-modes/base'
import
path
from
'path'
import
path
from
'path'
import
{
getSnapshotTestDescribe
}
from
'next-test-utils'
// TODO-APP: Investigate snapshot mismatch
// TODO-APP: Investigate snapshot mismatch
describe
(
'ReactRefreshLogBox app'
,
()
=>
{
for
(
const
variant
of
[
'default'
,
'turbo'
])
{
let
next
:
NextInstance
getSnapshotTestDescribe
(
variant
)(
`ReactRefreshLogBox app
${
variant
}
`
,
()
=>
{
let
next
:
NextInstance
beforeAll
(
async
()
=>
{
next
=
await
createNext
({
beforeAll
(
async
()
=>
{
files
:
new
FileRef
(
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)),
next
=
await
createNext
({
dependencies
:
{
files
:
new
FileRef
(
react
:
'latest'
,
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)
'react-dom'
:
'latest'
,
),
},
dependencies
:
{
skipStart
:
true
,
react
:
'latest'
,
'react-dom'
:
'latest'
,
},
skipStart
:
true
,
})
})
})
})
afterAll
(()
=>
next
.
destroy
())
afterAll
(()
=>
next
.
destroy
())
// Module trace is only available with webpack 5
// Module trace is only available with webpack 5
test
(
'Node.js builtins'
,
async
()
=>
{
test
(
'Node.js builtins'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
const
{
session
,
cleanup
}
=
await
sandbox
(
next
,
next
,
new
Map
([
new
Map
([
[
[
'node_modules/my-package/index.js'
,
'node_modules/my-package/index.js'
,
`
`
const dns = require('dns')
const dns = require('dns')
module.exports = dns
module.exports = dns
`
,
`
,
],
],
[
[
'node_modules/my-package/package.json'
,
'node_modules/my-package/package.json'
,
`
`
{
{
"name": "my-package",
"name": "my-package",
"version": "0.0.1"
"version": "0.0.1"
}
}
`
,
`
,
],
],
])
])
)
)
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
`
`
import pkg from 'my-package'
import pkg from 'my-package'
export default function Hello() {
export default function Hello() {
return (pkg ? <h1>Package loaded</h1> : <h1>Package did not load</h1>)
return (pkg ? <h1>Package loaded</h1> : <h1>Package did not load</h1>)
}
}
`
`
)
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
await
cleanup
()
await
cleanup
()
})
})
test
(
'Module not found'
,
async
()
=>
{
test
(
'Module not found'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
`import Comp from 'b'
`import Comp from 'b'
export default function Oops() {
export default function Oops() {
return (
return (
<div>
<div>
...
@@ -73,22 +77,22 @@ describe('ReactRefreshLogBox app', () => {
...
@@ -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
()
const
source
=
await
session
.
getRedboxSource
()
expect
(
source
).
toMatchSnapshot
()
expect
(
source
).
toMatchSnapshot
()
await
cleanup
()
await
cleanup
()
})
})
test
(
'Module not found empty import trace'
,
async
()
=>
{
test
(
'Module not found empty import trace'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
await
session
.
patch
(
await
session
.
patch
(
'app/page.js'
,
'app/page.js'
,
`'use client'
`'use client'
import Comp from 'b'
import Comp from 'b'
export default function Oops() {
export default function Oops() {
return (
return (
...
@@ -98,49 +102,50 @@ describe('ReactRefreshLogBox app', () => {
...
@@ -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
()
const
source
=
await
session
.
getRedboxSource
()
expect
(
source
).
toMatchSnapshot
()
expect
(
source
).
toMatchSnapshot
()
await
cleanup
()
await
cleanup
()
})
})
test
(
'Module not found missing global CSS'
,
async
()
=>
{
test
(
'Module not found missing global CSS'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
const
{
session
,
cleanup
}
=
await
sandbox
(
next
,
next
,
new
Map
([
new
Map
([
[
[
'app/page.js'
,
'app/page.js'
,
`'use client'
`'use client'
import './non-existent.css'
import './non-existent.css'
export default function Page(props) {
export default function Page(props) {
return <p>index page</p>
return <p>index page</p>
}
}
`
,
`
,
],
],
])
])
)
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
const
source
=
await
session
.
getRedboxSource
()
const
source
=
await
session
.
getRedboxSource
()
expect
(
source
).
toMatchSnapshot
()
expect
(
source
).
toMatchSnapshot
()
await
session
.
patch
(
await
session
.
patch
(
'app/page.js'
,
'app/page.js'
,
`'use client'
`'use client'
export default function Page(props) {
export default function Page(props) {
return <p>index page</p>
return <p>index page</p>
}
}
`
`
)
)
expect
(
await
session
.
hasRedbox
(
false
)).
toBe
(
false
)
expect
(
await
session
.
hasRedbox
(
false
)).
toBe
(
false
)
expect
(
expect
(
await
session
.
evaluate
(()
=>
document
.
documentElement
.
innerHTML
)
await
session
.
evaluate
(()
=>
document
.
documentElement
.
innerHTML
)
).
toContain
(
'index page'
)
).
toContain
(
'index page'
)
await
cleanup
()
await
cleanup
()
})
})
})
}
)
}
test/development/acceptance-app/ReactRefreshLogBox.test.ts
View file @
3e88af42
This diff is collapsed.
Click to expand it.
test/development/acceptance-app/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap
View file @
3e88af42
// Jest Snapshot v1, https://goo.gl/fbAQLP
// 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
"./index.js:1:0
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
> 1 | import Comp from 'b'
...
@@ -14,7 +14,7 @@ Import trace for requested module:
...
@@ -14,7 +14,7 @@ Import trace for requested module:
https://nextjs.org/docs/messages/module-not-found"
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
"./app/page.js:2:6
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
1 | 'use client'
1 | 'use client'
...
@@ -27,7 +27,7 @@ Module not found: Can't resolve 'b'
...
@@ -27,7 +27,7 @@ Module not found: Can't resolve 'b'
https://nextjs.org/docs/messages/module-not-found"
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
"./app/page.js:2:10
Module not found: Can't resolve './non-existent.css'
Module not found: Can't resolve './non-existent.css'
1 | 'use client'
1 | 'use client'
...
@@ -40,7 +40,7 @@ Module not found: Can't resolve './non-existent.css'
...
@@ -40,7 +40,7 @@ Module not found: Can't resolve './non-existent.css'
https://nextjs.org/docs/messages/module-not-found"
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
"./node_modules/my-package/index.js:2:0
Module not found: Can't resolve 'dns'
Module not found: Can't resolve 'dns'
...
...
test/development/acceptance-app/__snapshots__/ReactRefreshLogBox.test.ts.snap
View file @
3e88af42
// Jest Snapshot v1, https://goo.gl/fbAQLP
// 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.
"Error: Text content does not match server-rendered HTML.
See more info here: https://nextjs.org/docs/messages/react-hydration-error"
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
"index.js (4:16) @ default
2 | export default () => {
2 | export default () => {
...
@@ -18,14 +18,14 @@ exports[`ReactRefreshLogBox app Should not show __webpack_exports__ when exporti
...
@@ -18,14 +18,14 @@ exports[`ReactRefreshLogBox app Should not show __webpack_exports__ when exporti
7 | return null"
7 | return null"
`;
`;
exports[`ReactRefreshLogBox app boundaries 1`] = `
exports[`ReactRefreshLogBox app
default
boundaries 1`] = `
"FunctionDefault.js (1:50) @ FunctionDefault
"FunctionDefault.js (1:50) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
> 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
"Child.js (5:18) @ ClickCount.render
3 | export default class ClickCount extends Component {
3 | export default class ClickCount extends Component {
...
@@ -37,7 +37,7 @@ exports[`ReactRefreshLogBox app conversion to class component (1) 1`] = `
...
@@ -37,7 +37,7 @@ exports[`ReactRefreshLogBox app conversion to class component (1) 1`] = `
8 | "
8 | "
`;
`;
exports[`ReactRefreshLogBox app css syntax errors 1`] = `
exports[`ReactRefreshLogBox app
default
css syntax errors 1`] = `
"./index.module.css:1:1
"./index.module.css:1:1
Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id)
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
...
@@ -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
"child.js (4:16) @ Child
2 | // hello
2 | // hello
...
@@ -72,7 +72,7 @@ exports[`ReactRefreshLogBox app logbox: can recover from a component error 1`] =
...
@@ -72,7 +72,7 @@ exports[`ReactRefreshLogBox app logbox: can recover from a component error 1`] =
6 | "
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
"index.js (8:18) @ eval
6 | const increment = useCallback(() => {
6 | const increment = useCallback(() => {
...
@@ -84,7 +84,7 @@ exports[`ReactRefreshLogBox app logbox: can recover from a event handler error 1
...
@@ -84,7 +84,7 @@ exports[`ReactRefreshLogBox app logbox: can recover from a event handler error 1
11 | <main>"
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
"./index.js
Error:
Error:
x Unexpected eof
x Unexpected eof
...
@@ -101,7 +101,7 @@ Import trace for requested module:
...
@@ -101,7 +101,7 @@ Import trace for requested module:
./app/page.js"
./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
"index.js (4:14) @ eval
2 | // top offset for snapshot
2 | // top offset for snapshot
...
@@ -113,7 +113,7 @@ exports[`ReactRefreshLogBox app module init error not shown 1`] = `
...
@@ -113,7 +113,7 @@ exports[`ReactRefreshLogBox app module init error not shown 1`] = `
7 | return <h1>Default Export</h1>;"
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
"index.js (6:18) @ ClassDefault.render
4 | class ClassDefault extends React.Component {
4 | class ClassDefault extends React.Component {
...
@@ -125,7 +125,7 @@ exports[`ReactRefreshLogBox app render error not shown right after syntax error
...
@@ -125,7 +125,7 @@ exports[`ReactRefreshLogBox app render error not shown right after syntax error
9 | }"
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
"index.js (9:34) @ onClick
7 |
7 |
...
@@ -137,7 +137,7 @@ exports[`ReactRefreshLogBox app should strip whitespace correctly with newline 1
...
@@ -137,7 +137,7 @@ exports[`ReactRefreshLogBox app should strip whitespace correctly with newline 1
12 | </a>"
12 | </a>"
`;
`;
exports[`ReactRefreshLogBox app stuck error 1`] = `
exports[`ReactRefreshLogBox app
default
stuck error 1`] = `
"Foo.js (4:10) @ Foo
"Foo.js (4:10) @ Foo
2 | // intentionally skips export
2 | // intentionally skips export
...
@@ -148,7 +148,7 @@ exports[`ReactRefreshLogBox app stuck error 1`] = `
...
@@ -148,7 +148,7 @@ exports[`ReactRefreshLogBox app stuck error 1`] = `
6 | "
6 | "
`;
`;
exports[`ReactRefreshLogBox app syntax > runtime error 1`] = `
exports[`ReactRefreshLogBox app
default
syntax > runtime error 1`] = `
"index.js (6:16) @ Error
"index.js (6:16) @ Error
4 | setInterval(() => {
4 | setInterval(() => {
...
@@ -160,7 +160,7 @@ exports[`ReactRefreshLogBox app syntax > runtime error 1`] = `
...
@@ -160,7 +160,7 @@ exports[`ReactRefreshLogBox app syntax > runtime error 1`] = `
9 | return <div />"
9 | return <div />"
`;
`;
exports[`ReactRefreshLogBox app syntax > runtime error 2`] = `
exports[`ReactRefreshLogBox app
default
syntax > runtime error 2`] = `
"./index.js
"./index.js
Error:
Error:
x Expected '}', got '<eof>'
x Expected '}', got '<eof>'
...
@@ -182,7 +182,7 @@ Import trace for requested module:
...
@@ -182,7 +182,7 @@ Import trace for requested module:
./app/page.js"
./app/page.js"
`;
`;
exports[`ReactRefreshLogBox app syntax > runtime error 3`] = `
exports[`ReactRefreshLogBox app
default
syntax > runtime error 3`] = `
"./index.js
"./index.js
Error:
Error:
x Expected '}', got '<eof>'
x Expected '}', got '<eof>'
...
@@ -204,7 +204,7 @@ Import trace for requested module:
...
@@ -204,7 +204,7 @@ Import trace for requested module:
./app/page.js"
./app/page.js"
`;
`;
exports[`ReactRefreshLogBox app unterminated JSX 1`] = `
exports[`ReactRefreshLogBox app
default
unterminated JSX 1`] = `
"./index.js
"./index.js
Error:
Error:
x Unexpected token. Did you mean \`{'}'}\` or \`}\`?
x Unexpected token. Did you mean \`{'}'}\` or \`}\`?
...
...
test/development/acceptance/ReactRefreshLogBox-app-doc.test.ts
View file @
3e88af42
import
{
sandbox
}
from
'./helpers'
import
{
sandbox
}
from
'./helpers'
import
{
createNext
}
from
'e2e-utils'
import
{
createNext
}
from
'e2e-utils'
import
{
NextInstance
}
from
'test/lib/next-modes/base'
import
{
NextInstance
}
from
'test/lib/next-modes/base'
import
{
getSnapshotTestDescribe
}
from
'next-test-utils'
describe
(
'ReactRefreshLogBox'
,
()
=>
{
for
(
const
variant
of
[
'default'
,
'turbo'
])
{
let
next
:
NextInstance
getSnapshotTestDescribe
(
variant
)(
`ReactRefreshLogBox
${
variant
}
`
,
()
=>
{
let
next
:
NextInstance
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
next
=
await
createNext
({
next
=
await
createNext
({
files
:
{},
files
:
{},
skipStart
:
true
,
skipStart
:
true
,
})
})
})
})
afterAll
(()
=>
next
.
destroy
())
afterAll
(()
=>
next
.
destroy
())
test
(
'empty _app shows logbox'
,
async
()
=>
{
test
(
'empty _app shows logbox'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
const
{
session
,
cleanup
}
=
await
sandbox
(
next
,
next
,
new
Map
([
new
Map
([
[
[
'pages/_app.js'
,
'pages/_app.js'
,
`
`
`
,
`
,
],
],
])
])
)
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
`"Error: The default export is not a React Component in page: \\"/_app\\""`
`"Error: The default export is not a React Component in page: \\"/_app\\""`
)
)
await
session
.
patch
(
await
session
.
patch
(
'pages/_app.js'
,
'pages/_app.js'
,
`
`
function MyApp({ Component, pageProps }) {
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
return <Component {...pageProps} />;
}
}
export default MyApp
export default MyApp
`
`
)
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
await
cleanup
()
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
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
`"Error: The default export is not a React Component in page: \\"/_document\\""`
`"Error: The default export is not a React Component in page: \\"/_document\\""`
)
)
await
session
.
patch
(
await
session
.
patch
(
'pages/_document.js'
,
'pages/_document.js'
,
`
`
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
class MyDocument extends Document {
...
@@ -86,49 +88,49 @@ describe('ReactRefreshLogBox', () => {
...
@@ -86,49 +88,49 @@ describe('ReactRefreshLogBox', () => {
export default MyDocument
export default MyDocument
`
`
)
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
await
cleanup
()
await
cleanup
()
})
})
test
(
'_app syntax error shows logbox'
,
async
()
=>
{
test
(
'_app syntax error shows logbox'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
const
{
session
,
cleanup
}
=
await
sandbox
(
next
,
next
,
new
Map
([
new
Map
([
[
[
'pages/_app.js'
,
'pages/_app.js'
,
`
`
function MyApp({ Component, pageProps }) {
function MyApp({ Component, pageProps }) {
return <<Component {...pageProps} />;
return <<Component {...pageProps} />;
}
}
export default MyApp
export default MyApp
`
,
`
,
],
],
])
])
)
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
await
session
.
patch
(
await
session
.
patch
(
'pages/_app.js'
,
'pages/_app.js'
,
`
`
function MyApp({ Component, pageProps }) {
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
return <Component {...pageProps} />;
}
}
export default MyApp
export default MyApp
`
`
)
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
await
cleanup
()
await
cleanup
()
})
})
test
(
'_document syntax error shows logbox'
,
async
()
=>
{
test
(
'_document syntax error shows logbox'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
const
{
session
,
cleanup
}
=
await
sandbox
(
next
,
next
,
new
Map
([
new
Map
([
[
[
'pages/_document.js'
,
'pages/_document.js'
,
`
`
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {{
class MyDocument extends Document {{
...
@@ -152,15 +154,15 @@ describe('ReactRefreshLogBox', () => {
...
@@ -152,15 +154,15 @@ describe('ReactRefreshLogBox', () => {
export default MyDocument
export default MyDocument
`
,
`
,
],
],
])
])
)
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
await
session
.
patch
(
await
session
.
patch
(
'pages/_document.js'
,
'pages/_document.js'
,
`
`
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
class MyDocument extends Document {
...
@@ -184,8 +186,9 @@ describe('ReactRefreshLogBox', () => {
...
@@ -184,8 +186,9 @@ describe('ReactRefreshLogBox', () => {
export default MyDocument
export default MyDocument
`
`
)
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
expect
(
await
session
.
hasRedbox
()).
toBe
(
false
)
await
cleanup
()
await
cleanup
()
})
})
})
}
)
}
test/development/acceptance/ReactRefreshLogBox-builtins.test.ts
View file @
3e88af42
import
{
sandbox
}
from
'./helpers'
import
{
sandbox
}
from
'./helpers'
import
{
createNext
}
from
'e2e-utils'
import
{
createNext
}
from
'e2e-utils'
import
{
NextInstance
}
from
'test/lib/next-modes/base'
import
{
NextInstance
}
from
'test/lib/next-modes/base'
import
{
getSnapshotTestDescribe
}
from
'next-test-utils'
describe
(
'ReactRefreshLogBox'
,
()
=>
{
for
(
const
variant
of
[
'default'
,
'turbo'
])
{
let
next
:
NextInstance
getSnapshotTestDescribe
(
variant
)(
`ReactRefreshLogBox
${
variant
}
`
,
()
=>
{
let
next
:
NextInstance
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
next
=
await
createNext
({
next
=
await
createNext
({
files
:
{},
files
:
{},
skipStart
:
true
,
skipStart
:
true
,
})
})
})
})
afterAll
(()
=>
next
.
destroy
())
afterAll
(()
=>
next
.
destroy
())
// Module trace is only available with webpack 5
// Module trace is only available with webpack 5
test
(
'Node.js builtins'
,
async
()
=>
{
test
(
'Node.js builtins'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
const
{
session
,
cleanup
}
=
await
sandbox
(
next
,
next
,
new
Map
([
new
Map
([
[
[
'node_modules/my-package/index.js'
,
'node_modules/my-package/index.js'
,
`
`
const dns = require('dns')
const dns = require('dns')
module.exports = dns
module.exports = dns
`
,
`
,
],
],
[
[
'node_modules/my-package/package.json'
,
'node_modules/my-package/package.json'
,
`
`
{
{
"name": "my-package",
"name": "my-package",
"version": "0.0.1"
"version": "0.0.1"
}
}
`
,
`
,
],
],
])
])
)
)
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
`
`
import pkg from 'my-package'
import pkg from 'my-package'
export default function Hello() {
export default function Hello() {
return (pkg ? <h1>Package loaded</h1> : <h1>Package did not load</h1>)
return (pkg ? <h1>Package loaded</h1> : <h1>Package did not load</h1>)
}
}
`
`
)
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
expect
(
await
session
.
getRedboxSource
()).
toMatchSnapshot
()
await
cleanup
()
await
cleanup
()
})
})
test
(
'Module not found'
,
async
()
=>
{
test
(
'Module not found'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
`import Comp from 'b'
`import Comp from 'b'
export default function Oops() {
export default function Oops() {
return (
return (
<div>
<div>
...
@@ -67,22 +69,22 @@ describe('ReactRefreshLogBox', () => {
...
@@ -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
()
const
source
=
await
session
.
getRedboxSource
()
expect
(
source
).
toMatchSnapshot
()
expect
(
source
).
toMatchSnapshot
()
await
cleanup
()
await
cleanup
()
})
})
test
(
'Module not found (empty import trace)'
,
async
()
=>
{
test
(
'Module not found (empty import trace)'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
const
{
session
,
cleanup
}
=
await
sandbox
(
next
)
await
session
.
patch
(
await
session
.
patch
(
'pages/index.js'
,
'pages/index.js'
,
`import Comp from 'b'
`import Comp from 'b'
export default function Oops() {
export default function Oops() {
return (
return (
<div>
<div>
...
@@ -91,58 +93,59 @@ describe('ReactRefreshLogBox', () => {
...
@@ -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
()
const
source
=
await
session
.
getRedboxSource
()
expect
(
source
).
toMatchSnapshot
()
expect
(
source
).
toMatchSnapshot
()
await
cleanup
()
await
cleanup
()
})
})
test
(
'Module not found (missing global CSS)'
,
async
()
=>
{
test
(
'Module not found (missing global CSS)'
,
async
()
=>
{
const
{
session
,
cleanup
}
=
await
sandbox
(
const
{
session
,
cleanup
}
=
await
sandbox
(
next
,
next
,
new
Map
([
new
Map
([
[
[
'pages/_app.js'
,
'pages/_app.js'
,
`
`
import './non-existent.css'
import './non-existent.css'
export default function App({ Component, pageProps }) {
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
return <Component {...pageProps} />
}
}
`
,
`
,
],
],
[
[
'pages/index.js'
,
'pages/index.js'
,
`
`
export default function Page(props) {
export default function Page(props) {
return <p>index page</p>
return <p>index page</p>
}
}
`
,
`
,
],
],
])
])
)
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
const
source
=
await
session
.
getRedboxSource
()
const
source
=
await
session
.
getRedboxSource
()
expect
(
source
).
toMatchSnapshot
()
expect
(
source
).
toMatchSnapshot
()
await
session
.
patch
(
await
session
.
patch
(
'pages/_app.js'
,
'pages/_app.js'
,
`
`
export default function App({ Component, pageProps }) {
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
return <Component {...pageProps} />
}
}
`
`
)
)
expect
(
await
session
.
hasRedbox
(
false
)).
toBe
(
false
)
expect
(
await
session
.
hasRedbox
(
false
)).
toBe
(
false
)
expect
(
expect
(
await
session
.
evaluate
(()
=>
document
.
documentElement
.
innerHTML
)
await
session
.
evaluate
(()
=>
document
.
documentElement
.
innerHTML
)
).
toContain
(
'index page'
)
).
toContain
(
'index page'
)
await
cleanup
()
await
cleanup
()
})
})
})
}
)
}
test/development/acceptance/ReactRefreshLogBox.test.ts
View file @
3e88af42
This diff is collapsed.
Click to expand it.
test/development/acceptance/__snapshots__/ReactRefreshLogBox-app-doc.test.ts.snap
View file @
3e88af42
// Jest Snapshot v1, https://goo.gl/fbAQLP
// 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
"./pages/_app.js
Error:
Error:
x Expression expected
x Expression expected
...
@@ -30,7 +30,7 @@ Caused by:
...
@@ -30,7 +30,7 @@ Caused by:
1: Syntax Error"
1: Syntax Error"
`;
`;
exports[`ReactRefreshLogBox _document syntax error shows logbox 1`] = `
exports[`ReactRefreshLogBox
default
_document syntax error shows logbox 1`] = `
"./pages/_document.js
"./pages/_document.js
Error:
Error:
x Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key
x Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key
...
...
test/development/acceptance/__snapshots__/ReactRefreshLogBox-builtins.test.ts.snap
View file @
3e88af42
// Jest Snapshot v1, https://goo.gl/fbAQLP
// 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
"./pages/index.js:1:0
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
> 1 | import Comp from 'b'
...
@@ -11,20 +11,20 @@ Module not found: Can't resolve 'b'
...
@@ -11,20 +11,20 @@ Module not found: Can't resolve 'b'
https://nextjs.org/docs/messages/module-not-found"
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
"./pages/_app.js:2:8
Module not found: Can't resolve './non-existent.css'
Module not found: Can't resolve './non-existent.css'
1 |
1 |
> 2 | import './non-existent.css'
> 2 | import './non-existent.css'
| ^
| ^
3 |
3 |
4 | export default function App({ Component, pageProps }) {
4 | export default function App({ Component, pageProps }) {
5 | return <Component {...pageProps} />
5 | return <Component {...pageProps} />
https://nextjs.org/docs/messages/module-not-found"
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
"./index.js:1:0
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
> 1 | import Comp from 'b'
...
@@ -38,7 +38,7 @@ Import trace for requested module:
...
@@ -38,7 +38,7 @@ Import trace for requested module:
https://nextjs.org/docs/messages/module-not-found"
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
"./node_modules/my-package/index.js:2:0
Module not found: Can't resolve 'dns'
Module not found: Can't resolve 'dns'
...
...
test/development/acceptance/__snapshots__/ReactRefreshLogBox.test.ts.snap
View file @
3e88af42
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox boundaries 1`] = `
exports[`ReactRefreshLogBox
default
boundaries 1`] = `
"FunctionDefault.js (1:50) @ FunctionDefault
"FunctionDefault.js (1:50) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); }
> 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
"Child.js (5:18) @ ClickCount.render
3 | export default class ClickCount extends Component {
3 | export default class ClickCount extends Component {
...
@@ -19,7 +19,7 @@ exports[`ReactRefreshLogBox conversion to class component (1) 1`] = `
...
@@ -19,7 +19,7 @@ exports[`ReactRefreshLogBox conversion to class component (1) 1`] = `
8 | "
8 | "
`;
`;
exports[`ReactRefreshLogBox css syntax errors 1`] = `
exports[`ReactRefreshLogBox
default
css syntax errors 1`] = `
"./index.module.css:1:1
"./index.module.css:1:1
Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id)
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
...
@@ -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
"child.js (4:16) @ Child
2 | // hello
2 | // hello
...
@@ -54,7 +54,7 @@ exports[`ReactRefreshLogBox logbox: can recover from a component error 1`] = `
...
@@ -54,7 +54,7 @@ exports[`ReactRefreshLogBox logbox: can recover from a component error 1`] = `
6 | "
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
"index.js (8:18) @ eval
6 | const increment = useCallback(() => {
6 | const increment = useCallback(() => {
...
@@ -66,7 +66,7 @@ exports[`ReactRefreshLogBox logbox: can recover from a event handler error 1`] =
...
@@ -66,7 +66,7 @@ exports[`ReactRefreshLogBox logbox: can recover from a event handler error 1`] =
11 | <main>"
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
"./index.js
Error:
Error:
x Unexpected eof
x Unexpected eof
...
@@ -82,7 +82,7 @@ Import trace for requested module:
...
@@ -82,7 +82,7 @@ Import trace for requested module:
./index.js"
./index.js"
`;
`;
exports[`ReactRefreshLogBox module init error not shown 1`] = `
exports[`ReactRefreshLogBox
default
module init error not shown 1`] = `
"index.js (4:14) @ eval
"index.js (4:14) @ eval
2 | // top offset for snapshot
2 | // top offset for snapshot
...
@@ -94,7 +94,7 @@ exports[`ReactRefreshLogBox module init error not shown 1`] = `
...
@@ -94,7 +94,7 @@ exports[`ReactRefreshLogBox module init error not shown 1`] = `
7 | return <h1>Default Export</h1>;"
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
"index.js (6:18) @ ClassDefault.render
4 | class ClassDefault extends React.Component {
4 | class ClassDefault extends React.Component {
...
@@ -106,7 +106,7 @@ exports[`ReactRefreshLogBox render error not shown right after syntax error 1`]
...
@@ -106,7 +106,7 @@ exports[`ReactRefreshLogBox render error not shown right after syntax error 1`]
9 | }"
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
"index.js (9:34) @ onClick
7 |
7 |
...
@@ -118,7 +118,7 @@ exports[`ReactRefreshLogBox should strip whitespace correctly with newline 1`] =
...
@@ -118,7 +118,7 @@ exports[`ReactRefreshLogBox should strip whitespace correctly with newline 1`] =
12 | </a>"
12 | </a>"
`;
`;
exports[`ReactRefreshLogBox stuck error 1`] = `
exports[`ReactRefreshLogBox
default
stuck error 1`] = `
"Foo.js (4:10) @ Foo
"Foo.js (4:10) @ Foo
2 | // intentionally skips export
2 | // intentionally skips export
...
@@ -129,7 +129,7 @@ exports[`ReactRefreshLogBox stuck error 1`] = `
...
@@ -129,7 +129,7 @@ exports[`ReactRefreshLogBox stuck error 1`] = `
6 | "
6 | "
`;
`;
exports[`ReactRefreshLogBox syntax > runtime error 1`] = `
exports[`ReactRefreshLogBox
default
syntax > runtime error 1`] = `
"index.js (6:16) @ Error
"index.js (6:16) @ Error
4 | setInterval(() => {
4 | setInterval(() => {
...
@@ -141,7 +141,7 @@ exports[`ReactRefreshLogBox syntax > runtime error 1`] = `
...
@@ -141,7 +141,7 @@ exports[`ReactRefreshLogBox syntax > runtime error 1`] = `
9 | return <div />"
9 | return <div />"
`;
`;
exports[`ReactRefreshLogBox syntax > runtime error 2`] = `
exports[`ReactRefreshLogBox
default
syntax > runtime error 2`] = `
"./index.js
"./index.js
Error:
Error:
x Expected '}', got '<eof>'
x Expected '}', got '<eof>'
...
@@ -162,7 +162,7 @@ Import trace for requested module:
...
@@ -162,7 +162,7 @@ Import trace for requested module:
./index.js"
./index.js"
`;
`;
exports[`ReactRefreshLogBox syntax > runtime error 3`] = `
exports[`ReactRefreshLogBox
default
syntax > runtime error 3`] = `
"./index.js
"./index.js
Error:
Error:
x Expected '}', got '<eof>'
x Expected '}', got '<eof>'
...
@@ -183,7 +183,7 @@ Import trace for requested module:
...
@@ -183,7 +183,7 @@ Import trace for requested module:
./index.js"
./index.js"
`;
`;
exports[`ReactRefreshLogBox unterminated JSX 1`] = `
exports[`ReactRefreshLogBox
default
unterminated JSX 1`] = `
"./index.js
"./index.js
Error:
Error:
x Unexpected token. Did you mean \`{'}'}\` or \`}\`?
x Unexpected token. Did you mean \`{'}'}\` or \`}\`?
...
...
test/lib/next-test-utils.js
View file @
3e88af42
...
@@ -940,3 +940,20 @@ export function shouldRunTurboDevTest() {
...
@@ -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.
// If the test path matches the glob pattern, add additional case to run the test with `--turbo` flag.
return
isMatch
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment