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
4095ecb5
Unverified
Commit
4095ecb5
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 app/ ReactRefreshLogBox-builtins (#76394)
parent
4b23c7b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
93 deletions
+91
-93
ReactRefreshLogBox-builtins.test.ts
...opment/acceptance-app/ReactRefreshLogBox-builtins.test.ts
+91
-93
No files found.
test/development/acceptance-app/ReactRefreshLogBox-builtins.test.ts
View file @
4095ecb5
import
{
createSandbox
}
from
'development-sandbox'
import
{
createSandbox
}
from
'development-sandbox'
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
path
from
'path'
import
path
from
'path'
import
{
describeVariants
as
describe
}
from
'next-test-utils'
import
{
outdent
}
from
'outdent'
import
{
outdent
}
from
'outdent'
// TODO-APP: Investigate snapshot mismatch
describe
(
'ReactRefreshLogBox-builtins app'
,
()
=>
{
describe
.
each
([
'default'
,
'turbo'
])(
'ReactRefreshLogBox app %s'
,
()
=>
{
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
const
{
next
}
=
nextTestSetup
({
files
:
new
FileRef
(
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)),
files
:
new
FileRef
(
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)),
skipStart
:
true
,
skipStart
:
true
,
})
})
...
@@ -35,7 +33,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
...
@@ -35,7 +33,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
])
])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
...
@@ -47,37 +45,40 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
...
@@ -47,37 +45,40 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
}
}
`
`
)
)
await
session
.
assertHasRedbox
()
if
(
isTurbopack
)
{
if
(
process
.
env
.
TURBOPACK
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
{
"./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
./app/page.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'
,
...
@@ -93,42 +94,40 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
...
@@ -93,42 +94,40 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %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 | export default function Oops() {
"stack": [],
3 | return (
}
4 | <div>
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 | export default function Oops() {
"stack": [],
3 | return (
}
4 | <div>
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/page.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
(
'app/page.js'
,
'app/page.js'
,
...
@@ -145,34 +144,33 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
...
@@ -145,34 +144,33 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %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'",
"./app/page.js (2:1)
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.js (2:1)
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
1 | 'use client'
> 2 | import Comp from 'b'
> 2 | import Comp from 'b'
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^",
3 | export default function Oops() {
"stack": [],
4 | return (
}
5 | <div>
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./app/page.js (2:1)
{
"count": 1,
"description": "Module not found: Can't resolve 'b'",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.js (2:1)
Module not found: Can't resolve 'b'
Module not found: Can't resolve 'b'
1 | 'use client'
> 2 | import Comp from 'b'
> 2 | import Comp from 'b'
| ^
| ^",
3 | export default function Oops() {
"stack": [],
4 | return (
}
5 | <div>
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
}
})
})
...
@@ -193,37 +191,37 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
...
@@ -193,37 +191,37 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
],
],
])
])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
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 './non-existent.css'",
"./app/page.js (2:1)
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.js (2:1)
Module not found: Can't resolve './non-existent.css'
Module not found: Can't resolve './non-existent.css'
1 | 'use client'
> 2 | import './non-existent.css'
> 2 | import './non-existent.css'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^",
3 | export default function Page(props) {
"stack": [],
4 | return <p>index page</p>
}
5 | }
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./app/page.js (2:1)
{
"count": 1,
"description": "Module not found: Can't resolve './non-existent.css'",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.js (2:1)
Module not found: Can't resolve './non-existent.css'
Module not found: Can't resolve './non-existent.css'
1 | 'use client'
> 2 | import './non-existent.css'
> 2 | import './non-existent.css'
| ^
| ^",
3 | export default function Page(props) {
"stack": [],
4 | return <p>index page</p>
}
5 | }
https://nextjs.org/docs/messages/module-not-found"
`
)
`
)
}
}
await
session
.
patch
(
await
session
.
patch
(
'app/page.js'
,
'app/page.js'
,
outdent
`
outdent
`
...
...
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