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
0b49048a
Unverified
Commit
0b49048a
authored
Feb 23, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Feb 23, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Use new Redbox matchers in pages/ ReactRefreshLogBox-builtins (#76392)
parent
05f4b877
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
88 deletions
+92
-88
ReactRefreshLogBox-builtins.test.ts
...evelopment/acceptance/ReactRefreshLogBox-builtins.test.ts
+92
-88
No files found.
test/development/acceptance/ReactRefreshLogBox-builtins.test.ts
View file @
0b49048a
import
{
createSandbox
}
from
'development-sandbox'
import
{
createSandbox
}
from
'development-sandbox'
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
{
describeVariants
as
describe
}
from
'next-test-utils'
import
{
outdent
}
from
'outdent'
import
{
outdent
}
from
'outdent'
import
path
from
'path'
import
path
from
'path'
describe
.
each
([
'default'
,
'turbo'
])(
'ReactRefreshLogBox %s
'
,
()
=>
{
describe
(
'ReactRefreshLogBox
'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
files
:
new
FileRef
(
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)),
files
:
new
FileRef
(
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)),
skipStart
:
true
,
skipStart
:
true
,
})
})
...
@@ -33,7 +32,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
...
@@ -33,7 +32,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
],
],
])
])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
outdent
`
outdent
`
...
@@ -44,37 +43,41 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
...
@@ -44,37 +43,41 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
}
}
`
`
)
)
await
session
.
assertHasRedbox
()
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./node_modules/my-package/index.js (1:13)
{
"count": 1,
"description": "Module not found: Can't resolve 'dns'",
"environmentLabel": null,
"label": "Build Error",
"source": "./node_modules/my-package/index.js (1:13)
Module not found: Can't resolve 'dns'
Module not found: Can't resolve 'dns'
> 1 | const dns = require('dns')
> 1 | const dns = require('dns')
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^",
2 | module.exports = dns
"stack": [],
}
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
else
{
}
else
{
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./node_modules/my-package/index.js (1:1)
{
"count": 1,
"description": "Module not found: Can't resolve 'dns'",
"environmentLabel": null,
"label": "Build Error",
"source": "./node_modules/my-package/index.js (1:1)
Module not found: Can't resolve 'dns'
Module not found: Can't resolve 'dns'
> 1 | const dns = require('dns')
> 1 | const dns = require('dns')
| ^
| ^",
2 | module.exports = dns
"stack": [],
}
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./index.js
./pages/index.js"
`
)
`
)
}
}
})
})
test
(
'Module not found'
,
async
()
=>
{
test
(
'Module not found'
,
async
()
=>
{
await
using
sandbox
=
await
createSandbox
(
next
)
await
using
sandbox
=
await
createSandbox
(
next
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
...
@@ -91,42 +94,40 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
...
@@ -91,42 +94,40 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
`
`
)
)
await
session
.
assertHasRedbox
()
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
const
source
=
await
session
.
getRedboxSource
()
{
if
(
process
.
env
.
TURBOPACK
)
{
"count": 1,
expect
(
source
).
toMatchInlineSnapshot
(
`
"description": "Module not found: Can't resolve 'b'",
"./index.js (1:1)
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js (1:1)
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
> 1 | import Comp from 'b'
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^",
2 |
"stack": [],
3 | export default function Oops() {
}
4 | return (
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./index.js (1:1)
{
"count": 1,
"description": "Module not found: Can't resolve 'b'",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js (1:1)
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
> 1 | import Comp from 'b'
| ^
| ^",
2 |
"stack": [],
3 | export default function Oops() {
}
4 | return (
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./pages/index.js"
`
)
`
)
}
}
})
})
test
(
'Module not found (empty import trace)'
,
async
()
=>
{
test
(
'Module not found (empty import trace)'
,
async
()
=>
{
await
using
sandbox
=
await
createSandbox
(
next
)
await
using
sandbox
=
await
createSandbox
(
next
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
patch
(
await
session
.
patch
(
'pages/index.js'
,
'pages/index.js'
,
...
@@ -143,32 +144,33 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
...
@@ -143,32 +144,33 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
`
`
)
)
await
session
.
assertHasRedbox
()
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
const
source
=
await
session
.
getRedboxSource
()
{
if
(
process
.
env
.
TURBOPACK
)
{
"count": 1,
expect
(
source
).
toMatchInlineSnapshot
(
`
"description": "Module not found: Can't resolve 'b'",
"./pages/index.js (1:1)
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/index.js (1:1)
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
> 1 | import Comp from 'b'
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^",
2 |
"stack": [],
3 | export default function Oops() {
}
4 | return (
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./pages/index.js (1:1)
{
"count": 1,
"description": "Module not found: Can't resolve 'b'",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/index.js (1:1)
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
> 1 | import Comp from 'b'
| ^
| ^",
2 |
"stack": [],
3 | export default function Oops() {
}
4 | return (
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
}
})
})
...
@@ -197,33 +199,35 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
...
@@ -197,33 +199,35 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
],
],
])
])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
assertHasRedbox
()
if
(
isTurbopack
)
{
const
source
=
await
session
.
getRedboxSource
()
await
expect
(
browser
).
toDisplayRedbox
(
`
if
(
process
.
env
.
TURBOPACK
)
{
{
expect
(
source
).
toMatchInlineSnapshot
(
`
"count": 1,
"./pages/_app.js (1:1)
"description": "Module not found: Can't resolve './non-existent.css'",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/_app.js (1:1)
Module not found: Can't resolve './non-existent.css'
Module not found: Can't resolve './non-existent.css'
> 1 | import './non-existent.css'
> 1 | import './non-existent.css'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^",
2 |
"stack": [],
3 | export default function App({ Component, pageProps }) {
}
4 | return <Component {...pageProps} />
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./pages/_app.js (1:1)
{
"count": 1,
"description": "Module not found: Can't resolve './non-existent.css'",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/_app.js (1:1)
Module not found: Can't resolve './non-existent.css'
Module not found: Can't resolve './non-existent.css'
> 1 | import './non-existent.css'
> 1 | import './non-existent.css'
| ^
| ^",
2 |
"stack": [],
3 | export default function App({ Component, pageProps }) {
}
4 | return <Component {...pageProps} />
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
}
...
...
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