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
54a9be44
Commit
54a9be44
authored
Sep 12, 2025
by
Niklas Mischkulnig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP test
parent
c6d2c932
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
4472 additions
and
0 deletions
+4472
-0
page.js
test/e2e/app-dir/app-0app/app/back-forward/[id]/page.js
+26
-0
ClientComponent.js
...dir/app-0app/app/bootstrap/[[...rest]]/ClientComponent.js
+11
-0
page.js
test/e2e/app-dir/app-0app/app/bootstrap/[[...rest]]/page.js
+15
-0
layout.js
test/e2e/app-dir/app-0app/app/layout.js
+26
-0
not-found.module.css
test/e2e/app-dir/app-0app/app/not-found.module.css
+3
-0
style.css
test/e2e/app-dir/app-0app/app/style.css
+3
-0
button.js
test/e2e/app-dir/app-0app/components/button/button.js
+15
-0
button.module.css
.../e2e/app-dir/app-0app/components/button/button.module.css
+4
-0
experimental-compile.test.ts
test/e2e/app-dir/app-0app/experimental-compile.test.ts
+9
-0
index.test.ts
test/e2e/app-dir/app-0app/index.test.ts
+1873
-0
next.config.js
test/e2e/app-dir/app-0app/next.config.js
+27
-0
hello.txt
test/e2e/app-dir/app-0app/public/hello.txt
+1
-0
noop-test.js
test/e2e/app-dir/app-0app/public/noop-test.js
+1
-0
test1.js
test/e2e/app-dir/app-0app/public/test1.js
+2
-0
test2.js
test/e2e/app-dir/app-0app/public/test2.js
+2
-0
test3.js
test/e2e/app-dir/app-0app/public/test3.js
+2
-0
test4.js
test/e2e/app-dir/app-0app/public/test4.js
+2
-0
standalone-gsp.test.ts
test/e2e/app-dir/app-0app/standalone-gsp.test.ts
+88
-0
standalone.test.ts
test/e2e/app-dir/app-0app/standalone.test.ts
+106
-0
global.css
test/e2e/app-dir/app-0app/styles/global.css
+3
-0
shared.module.css
test/e2e/app-dir/app-0app/styles/shared.module.css
+3
-0
useReportWebVitals.test.ts
test/e2e/app-dir/app-0app/useReportWebVitals.test.ts
+48
-0
button.js
test/e2e/app-dir/app-0pages/components/button/button.js
+15
-0
button.module.css
...2e/app-dir/app-0pages/components/button/button.module.css
+4
-0
experimental-compile.test.ts
test/e2e/app-dir/app-0pages/experimental-compile.test.ts
+9
-0
index.test.ts
test/e2e/app-dir/app-0pages/index.test.ts
+1873
-0
next.config.js
test/e2e/app-dir/app-0pages/next.config.js
+27
-0
ssr.js
test/e2e/app-dir/app-0pages/pages/ssr.js
+16
-0
hello.txt
test/e2e/app-dir/app-0pages/public/hello.txt
+1
-0
noop-test.js
test/e2e/app-dir/app-0pages/public/noop-test.js
+1
-0
test1.js
test/e2e/app-dir/app-0pages/public/test1.js
+2
-0
test2.js
test/e2e/app-dir/app-0pages/public/test2.js
+2
-0
test3.js
test/e2e/app-dir/app-0pages/public/test3.js
+2
-0
test4.js
test/e2e/app-dir/app-0pages/public/test4.js
+2
-0
standalone-gsp.test.ts
test/e2e/app-dir/app-0pages/standalone-gsp.test.ts
+88
-0
standalone.test.ts
test/e2e/app-dir/app-0pages/standalone.test.ts
+106
-0
global.css
test/e2e/app-dir/app-0pages/styles/global.css
+3
-0
shared.module.css
test/e2e/app-dir/app-0pages/styles/shared.module.css
+3
-0
useReportWebVitals.test.ts
test/e2e/app-dir/app-0pages/useReportWebVitals.test.ts
+48
-0
No files found.
test/e2e/app-dir/app-0app/app/back-forward/[id]/page.js
0 → 100644
View file @
54a9be44
'use client'
import
{
use
}
from
'react'
import
Link
from
'next/link'
import
{
useRouter
}
from
'next/navigation'
export
default
function
Page
(
props
)
{
const
params
=
use
(
props
.
params
)
const
router
=
useRouter
()
return
(
<>
<
h1
id
=
{
`message-
${
params
.
id
}
`
}
>
Hello
from
{
params
.
id
}
<
/h1
>
<
Link
href
=
{
params
.
id
===
'1'
?
'/back-forward/2'
:
'/back-forward/1'
}
id
=
"to-other-page"
>
Go
to
{
params
.
id
===
'1'
?
'2'
:
'1'
}
<
/Link
>
<
button
onClick
=
{()
=>
router
.
back
()}
id
=
"back-button"
>
Back
<
/button
>
<
button
onClick
=
{()
=>
router
.
forward
()}
id
=
"forward-button"
>
Forward
<
/button
>
<
/
>
)
}
test/e2e/app-dir/app-0app/app/bootstrap/[[...rest]]/ClientComponent.js
0 → 100644
View file @
54a9be44
'use client'
import
{
useState
,
useEffect
}
from
'react'
export
function
ClientComponent
()
{
const
[
val
,
setVal
]
=
useState
(
'initial'
)
useEffect
(()
=>
{
setVal
(
'[[updated]]'
)
},
[])
return
<
span
id
=
"val"
>
{
val
}
<
/span
>
}
test/e2e/app-dir/app-0app/app/bootstrap/[[...rest]]/page.js
0 → 100644
View file @
54a9be44
import
{
ClientComponent
}
from
'./ClientComponent'
export
default
async
function
Page
()
{
return
(
<>
<
div
>
This
fixture
is
to
assert
where
the
bootstrap
scripts
and
other
required
scripts
emit
during
SSR
<
/div
>
<
div
>
<
ClientComponent
/>
<
/div
>
<
/
>
)
}
test/e2e/app-dir/app-0app/app/layout.js
0 → 100644
View file @
54a9be44
import
{
use
}
from
'react'
import
'../styles/global.css'
import
'./style.css'
export
const
revalidate
=
0
export
const
preferredRegion
=
'sfo1'
async
function
getData
()
{
return
{
world
:
'world'
,
}
}
export
default
function
Root
({
children
})
{
const
{
world
}
=
use
(
getData
())
return
(
<
html
className
=
"this-is-the-document-html"
>
<
head
>
<
title
>
{
`hello
${
world
}
`
}
<
/title
>
<
/head
>
<
body
className
=
"this-is-the-document-body"
>
{
children
}
<
/body
>
<
/html
>
)
}
test/e2e/app-dir/app-0app/app/not-found.module.css
0 → 100644
View file @
54a9be44
.text
{
color
:
cyan
;
}
test/e2e/app-dir/app-0app/app/style.css
0 → 100644
View file @
54a9be44
body
{
font-size
:
large
;
}
test/e2e/app-dir/app-0app/components/button/button.js
0 → 100644
View file @
54a9be44
'use client'
import
*
as
buttonStyle
from
'./button.module.css'
export
function
Button
({
children
})
{
return
(
<
button
className
=
{
buttonStyle
.
button
}
onClick
=
{()
=>
{
console
.
log
(
'clicked button!'
)
}}
>
{
children
}
<
/button
>
)
}
test/e2e/app-dir/app-0app/components/button/button.module.css
0 → 100644
View file @
54a9be44
.button
{
background
:
#000
;
color
:
#fff
;
}
test/e2e/app-dir/app-0app/experimental-compile.test.ts
0 → 100644
View file @
54a9be44
import
'e2e-utils'
process
.
env
.
NEXT_EXPERIMENTAL_COMPILE
=
'1'
if
((
global
as
any
).
isNextStart
)
{
require
(
'./index.test'
)
}
else
{
it
(
'should skip'
,
()
=>
{})
}
test/e2e/app-dir/app-0app/index.test.ts
0 → 100644
View file @
54a9be44
This diff is collapsed.
Click to expand it.
test/e2e/app-dir/app-0app/next.config.js
0 → 100644
View file @
54a9be44
/**
* @type import('next').NextConfig
*/
module
.
exports
=
{
env
:
{
LEGACY_ENV_KEY
:
'1'
,
},
experimental
:
{
clientRouterFilterRedirects
:
true
,
parallelServerCompiles
:
true
,
parallelServerBuildTraces
:
true
,
webpackBuildWorker
:
true
,
// turbopackMinify: false,
},
distDir
:
process
.
env
.
TURBOPACK
?
'.next-turbopack'
:
'.next'
,
typescript
:
{
ignoreBuildErrors
:
true
,
},
turbopack
:
{
moduleIds
:
'named'
,
},
webpack
(
config
)
{
config
.
optimization
.
moduleIds
=
'named'
// config.optimization.minimize = false
return
config
},
}
test/e2e/app-dir/app-0app/public/hello.txt
0 → 100644
View file @
54a9be44
hello world
\ No newline at end of file
test/e2e/app-dir/app-0app/public/noop-test.js
0 → 100644
View file @
54a9be44
console
.
log
(
'test-noop'
)
test/e2e/app-dir/app-0app/public/test1.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
1
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0app/public/test2.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
2
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0app/public/test3.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
3
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0app/public/test4.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
4
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0app/standalone-gsp.test.ts
0 → 100644
View file @
54a9be44
import
{
nextTestSetup
}
from
'e2e-utils'
import
fs
from
'fs-extra'
import
os
from
'os'
import
path
from
'path'
import
{
findPort
,
initNextServerScript
,
killApp
,
fetchViaHTTP
,
}
from
'next-test-utils'
if
(
!
(
globalThis
as
any
).
isNextStart
)
{
it
(
'should skip for non-next start'
,
()
=>
{})
}
else
{
describe
(
'output: standalone with getStaticProps'
,
()
=>
{
const
{
next
,
skipped
}
=
nextTestSetup
({
files
:
__dirname
,
skipStart
:
true
,
dependencies
:
{
swr
:
'latest'
,
nanoid
:
'4.0.1'
,
},
})
if
(
skipped
)
{
return
}
beforeAll
(
async
()
=>
{
await
next
.
patchFile
(
'next.config.js'
,
(
await
next
.
readFile
(
'next.config.js'
)).
replace
(
'// output'
,
'output'
)
)
await
next
.
patchFile
(
'pages/gsp.js'
,
`
import useSWR from 'swr'
console.log(useSWR)
export default function Home() {
return <h1>Hello</h1>
}
export async function getStaticProps() {
return {
props: {
foo: "bar",
},
};
}
`
)
await
next
.
start
()
})
it
(
'should work correctly with output standalone'
,
async
()
=>
{
const
tmpFolder
=
path
.
join
(
os
.
tmpdir
(),
'next-standalone-'
+
Date
.
now
())
await
fs
.
move
(
path
.
join
(
next
.
testDir
,
'.next/standalone'
),
tmpFolder
)
let
server
:
any
try
{
const
testServer
=
path
.
join
(
tmpFolder
,
'server.js'
)
const
appPort
=
await
findPort
()
server
=
await
initNextServerScript
(
testServer
,
/- Local:/
,
{
...
process
.
env
,
PORT
:
appPort
.
toString
(),
},
undefined
,
{
cwd
:
tmpFolder
,
}
)
const
res
=
await
fetchViaHTTP
(
appPort
,
'/gsp'
)
expect
(
res
.
status
).
toBe
(
200
)
}
finally
{
if
(
server
)
await
killApp
(
server
)
await
fs
.
remove
(
tmpFolder
)
}
})
})
}
test/e2e/app-dir/app-0app/standalone.test.ts
0 → 100644
View file @
54a9be44
import
{
nextTestSetup
}
from
'e2e-utils'
import
fs
from
'fs-extra'
import
os
from
'os'
import
path
from
'path'
import
{
findPort
,
initNextServerScript
,
killApp
,
fetchViaHTTP
,
}
from
'next-test-utils'
if
(
!
(
globalThis
as
any
).
isNextStart
)
{
it
(
'should skip for non-next start'
,
()
=>
{})
}
else
{
describe
(
'output: standalone with app dir'
,
()
=>
{
const
{
next
,
skipped
}
=
nextTestSetup
({
files
:
__dirname
,
skipStart
:
true
,
dependencies
:
{
nanoid
:
'4.0.1'
,
},
})
if
(
skipped
)
{
return
}
beforeAll
(
async
()
=>
{
await
next
.
patchFile
(
'next.config.js'
,
(
await
next
.
readFile
(
'next.config.js'
)).
replace
(
'// output'
,
'output'
)
)
await
next
.
start
()
})
it
(
'should handle trace files correctly for route groups (nodejs only)'
,
async
()
=>
{
expect
(
next
.
cliOutput
).
not
.
toContain
(
'Failed to copy traced files'
)
const
serverDirPath
=
path
.
join
(
next
.
testDir
,
'.next/standalone/.next/server'
)
for
(
const
page
of
[
'(newroot)/dashboard/another'
,
'(newroot)/dashboard/project/[projectId]'
,
'(rootonly)/dashboard/changelog'
,
])
{
const
pagePath
=
path
.
join
(
serverDirPath
,
'app'
,
page
)
expect
(
await
fs
.
pathExists
(
path
.
join
(
pagePath
,
'page.js.nft.json'
))
).
toBe
(
true
)
const
files
=
(
await
fs
.
readJSON
(
path
.
join
(
pagePath
,
'page.js.nft.json'
))
).
files
as
string
[]
for
(
const
file
of
files
)
{
expect
(
await
fs
.
pathExists
(
path
.
join
(
pagePath
,
file
))).
toBe
(
true
)
}
}
})
it
(
'should work correctly with output standalone'
,
async
()
=>
{
const
tmpFolder
=
path
.
join
(
os
.
tmpdir
(),
'next-standalone-'
+
Date
.
now
())
await
fs
.
move
(
path
.
join
(
next
.
testDir
,
'.next/standalone'
),
tmpFolder
)
let
server
:
any
try
{
const
testServer
=
path
.
join
(
tmpFolder
,
'server.js'
)
const
appPort
=
await
findPort
()
server
=
await
initNextServerScript
(
testServer
,
/- Local:/
,
{
...
process
.
env
,
PORT
:
appPort
.
toString
(),
},
undefined
,
{
cwd
:
tmpFolder
,
}
)
for
(
const
testPath
of
[
'/'
,
'/api/hello'
,
'/blog/first'
,
'/dashboard'
,
'/dashboard/another'
,
'/dashboard/changelog'
,
'/dashboard/deployments/breakdown'
,
'/dashboard/deployments/123'
,
'/dashboard/hello'
,
'/dashboard/project/123'
,
'/catch-all/first'
,
])
{
const
res
=
await
fetchViaHTTP
(
appPort
,
testPath
)
expect
(
res
.
status
).
toBe
(
200
)
}
}
finally
{
if
(
server
)
await
killApp
(
server
)
await
fs
.
remove
(
tmpFolder
)
}
})
})
}
test/e2e/app-dir/app-0app/styles/global.css
0 → 100644
View file @
54a9be44
.bold
{
font-weight
:
bold
;
}
test/e2e/app-dir/app-0app/styles/shared.module.css
0 → 100644
View file @
54a9be44
.content
{
color
:
blueviolet
;
}
test/e2e/app-dir/app-0app/useReportWebVitals.test.ts
0 → 100644
View file @
54a9be44
import
{
createNext
}
from
'e2e-utils'
import
{
NextInstance
}
from
'e2e-utils'
import
{
check
}
from
'next-test-utils'
describe
(
'useReportWebVitals hook'
,
()
=>
{
let
next
:
NextInstance
beforeAll
(
async
()
=>
{
next
=
await
createNext
({
files
:
__dirname
,
skipStart
:
true
,
env
:
{},
dependencies
:
{
nanoid
:
'4.0.1'
,
},
})
await
next
.
start
()
})
afterAll
(()
=>
next
.
destroy
())
// Analytics events are only sent in production
it
(
'should send web-vitals'
,
async
()
=>
{
await
next
.
fetch
(
'/report-web-vitals'
)
let
eventsCount
=
0
const
browser
=
await
next
.
browser
(
'/report-web-vitals'
,
{
beforePageLoad
:
(
page
)
=>
{
page
.
route
(
'https://example.vercel.sh/vitals'
,
(
route
)
=>
{
eventsCount
+=
1
route
.
fulfill
()
})
},
})
// Refresh will trigger CLS and LCP. When page loads FCP and TTFB will trigger:
await
browser
.
refresh
()
// After interaction LCP and FID will trigger
await
browser
.
elementById
(
'btn'
).
click
()
// Make sure all registered events in performance-relayer has fired
await
check
(
async
()
=>
{
expect
(
eventsCount
).
toBeGreaterThanOrEqual
(
6
)
return
'success'
},
'success'
)
})
})
test/e2e/app-dir/app-0pages/components/button/button.js
0 → 100644
View file @
54a9be44
'use client'
import
*
as
buttonStyle
from
'./button.module.css'
export
function
Button
({
children
})
{
return
(
<
button
className
=
{
buttonStyle
.
button
}
onClick
=
{()
=>
{
console
.
log
(
'clicked button!'
)
}}
>
{
children
}
<
/button
>
)
}
test/e2e/app-dir/app-0pages/components/button/button.module.css
0 → 100644
View file @
54a9be44
.button
{
background
:
#000
;
color
:
#fff
;
}
test/e2e/app-dir/app-0pages/experimental-compile.test.ts
0 → 100644
View file @
54a9be44
import
'e2e-utils'
process
.
env
.
NEXT_EXPERIMENTAL_COMPILE
=
'1'
if
((
global
as
any
).
isNextStart
)
{
require
(
'./index.test'
)
}
else
{
it
(
'should skip'
,
()
=>
{})
}
test/e2e/app-dir/app-0pages/index.test.ts
0 → 100644
View file @
54a9be44
This diff is collapsed.
Click to expand it.
test/e2e/app-dir/app-0pages/next.config.js
0 → 100644
View file @
54a9be44
/**
* @type import('next').NextConfig
*/
module
.
exports
=
{
env
:
{
LEGACY_ENV_KEY
:
'1'
,
},
experimental
:
{
clientRouterFilterRedirects
:
true
,
parallelServerCompiles
:
true
,
parallelServerBuildTraces
:
true
,
webpackBuildWorker
:
true
,
turbopackMinify
:
false
,
},
distDir
:
process
.
env
.
TURBOPACK
?
'.next-turbopack'
:
'.next'
,
typescript
:
{
ignoreBuildErrors
:
true
,
},
turbopack
:
{
moduleIds
:
'named'
,
},
webpack
(
config
)
{
config
.
optimization
.
moduleIds
=
'named'
config
.
optimization
.
minimize
=
false
return
config
},
}
test/e2e/app-dir/app-0pages/pages/ssr.js
0 → 100644
View file @
54a9be44
// import { useRouter } from 'next/router'
export
default
function
Page
(
props
)
{
return
(
<>
<
p
>
hello
from
ssr
<
/p
>
{
/* <p id="query">{JSON.stringify(useRouter().query)}</p> */
}
<
/
>
)
}
export
function
getServerSideProps
()
{
return
{
props
:
{},
}
}
test/e2e/app-dir/app-0pages/public/hello.txt
0 → 100644
View file @
54a9be44
hello world
\ No newline at end of file
test/e2e/app-dir/app-0pages/public/noop-test.js
0 → 100644
View file @
54a9be44
console
.
log
(
'test-noop'
)
test/e2e/app-dir/app-0pages/public/test1.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
1
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0pages/public/test2.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
2
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0pages/public/test3.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
3
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0pages/public/test4.js
0 → 100644
View file @
54a9be44
;(
window
.
_script_order
=
window
.
_script_order
||
[]).
push
(
4
)
console
.
log
(
window
.
_script_order
)
test/e2e/app-dir/app-0pages/standalone-gsp.test.ts
0 → 100644
View file @
54a9be44
import
{
nextTestSetup
}
from
'e2e-utils'
import
fs
from
'fs-extra'
import
os
from
'os'
import
path
from
'path'
import
{
findPort
,
initNextServerScript
,
killApp
,
fetchViaHTTP
,
}
from
'next-test-utils'
if
(
!
(
globalThis
as
any
).
isNextStart
)
{
it
(
'should skip for non-next start'
,
()
=>
{})
}
else
{
describe
(
'output: standalone with getStaticProps'
,
()
=>
{
const
{
next
,
skipped
}
=
nextTestSetup
({
files
:
__dirname
,
skipStart
:
true
,
dependencies
:
{
swr
:
'latest'
,
nanoid
:
'4.0.1'
,
},
})
if
(
skipped
)
{
return
}
beforeAll
(
async
()
=>
{
await
next
.
patchFile
(
'next.config.js'
,
(
await
next
.
readFile
(
'next.config.js'
)).
replace
(
'// output'
,
'output'
)
)
await
next
.
patchFile
(
'pages/gsp.js'
,
`
import useSWR from 'swr'
console.log(useSWR)
export default function Home() {
return <h1>Hello</h1>
}
export async function getStaticProps() {
return {
props: {
foo: "bar",
},
};
}
`
)
await
next
.
start
()
})
it
(
'should work correctly with output standalone'
,
async
()
=>
{
const
tmpFolder
=
path
.
join
(
os
.
tmpdir
(),
'next-standalone-'
+
Date
.
now
())
await
fs
.
move
(
path
.
join
(
next
.
testDir
,
'.next/standalone'
),
tmpFolder
)
let
server
:
any
try
{
const
testServer
=
path
.
join
(
tmpFolder
,
'server.js'
)
const
appPort
=
await
findPort
()
server
=
await
initNextServerScript
(
testServer
,
/- Local:/
,
{
...
process
.
env
,
PORT
:
appPort
.
toString
(),
},
undefined
,
{
cwd
:
tmpFolder
,
}
)
const
res
=
await
fetchViaHTTP
(
appPort
,
'/gsp'
)
expect
(
res
.
status
).
toBe
(
200
)
}
finally
{
if
(
server
)
await
killApp
(
server
)
await
fs
.
remove
(
tmpFolder
)
}
})
})
}
test/e2e/app-dir/app-0pages/standalone.test.ts
0 → 100644
View file @
54a9be44
import
{
nextTestSetup
}
from
'e2e-utils'
import
fs
from
'fs-extra'
import
os
from
'os'
import
path
from
'path'
import
{
findPort
,
initNextServerScript
,
killApp
,
fetchViaHTTP
,
}
from
'next-test-utils'
if
(
!
(
globalThis
as
any
).
isNextStart
)
{
it
(
'should skip for non-next start'
,
()
=>
{})
}
else
{
describe
(
'output: standalone with app dir'
,
()
=>
{
const
{
next
,
skipped
}
=
nextTestSetup
({
files
:
__dirname
,
skipStart
:
true
,
dependencies
:
{
nanoid
:
'4.0.1'
,
},
})
if
(
skipped
)
{
return
}
beforeAll
(
async
()
=>
{
await
next
.
patchFile
(
'next.config.js'
,
(
await
next
.
readFile
(
'next.config.js'
)).
replace
(
'// output'
,
'output'
)
)
await
next
.
start
()
})
it
(
'should handle trace files correctly for route groups (nodejs only)'
,
async
()
=>
{
expect
(
next
.
cliOutput
).
not
.
toContain
(
'Failed to copy traced files'
)
const
serverDirPath
=
path
.
join
(
next
.
testDir
,
'.next/standalone/.next/server'
)
for
(
const
page
of
[
'(newroot)/dashboard/another'
,
'(newroot)/dashboard/project/[projectId]'
,
'(rootonly)/dashboard/changelog'
,
])
{
const
pagePath
=
path
.
join
(
serverDirPath
,
'app'
,
page
)
expect
(
await
fs
.
pathExists
(
path
.
join
(
pagePath
,
'page.js.nft.json'
))
).
toBe
(
true
)
const
files
=
(
await
fs
.
readJSON
(
path
.
join
(
pagePath
,
'page.js.nft.json'
))
).
files
as
string
[]
for
(
const
file
of
files
)
{
expect
(
await
fs
.
pathExists
(
path
.
join
(
pagePath
,
file
))).
toBe
(
true
)
}
}
})
it
(
'should work correctly with output standalone'
,
async
()
=>
{
const
tmpFolder
=
path
.
join
(
os
.
tmpdir
(),
'next-standalone-'
+
Date
.
now
())
await
fs
.
move
(
path
.
join
(
next
.
testDir
,
'.next/standalone'
),
tmpFolder
)
let
server
:
any
try
{
const
testServer
=
path
.
join
(
tmpFolder
,
'server.js'
)
const
appPort
=
await
findPort
()
server
=
await
initNextServerScript
(
testServer
,
/- Local:/
,
{
...
process
.
env
,
PORT
:
appPort
.
toString
(),
},
undefined
,
{
cwd
:
tmpFolder
,
}
)
for
(
const
testPath
of
[
'/'
,
'/api/hello'
,
'/blog/first'
,
'/dashboard'
,
'/dashboard/another'
,
'/dashboard/changelog'
,
'/dashboard/deployments/breakdown'
,
'/dashboard/deployments/123'
,
'/dashboard/hello'
,
'/dashboard/project/123'
,
'/catch-all/first'
,
])
{
const
res
=
await
fetchViaHTTP
(
appPort
,
testPath
)
expect
(
res
.
status
).
toBe
(
200
)
}
}
finally
{
if
(
server
)
await
killApp
(
server
)
await
fs
.
remove
(
tmpFolder
)
}
})
})
}
test/e2e/app-dir/app-0pages/styles/global.css
0 → 100644
View file @
54a9be44
.bold
{
font-weight
:
bold
;
}
test/e2e/app-dir/app-0pages/styles/shared.module.css
0 → 100644
View file @
54a9be44
.content
{
color
:
blueviolet
;
}
test/e2e/app-dir/app-0pages/useReportWebVitals.test.ts
0 → 100644
View file @
54a9be44
import
{
createNext
}
from
'e2e-utils'
import
{
NextInstance
}
from
'e2e-utils'
import
{
check
}
from
'next-test-utils'
describe
(
'useReportWebVitals hook'
,
()
=>
{
let
next
:
NextInstance
beforeAll
(
async
()
=>
{
next
=
await
createNext
({
files
:
__dirname
,
skipStart
:
true
,
env
:
{},
dependencies
:
{
nanoid
:
'4.0.1'
,
},
})
await
next
.
start
()
})
afterAll
(()
=>
next
.
destroy
())
// Analytics events are only sent in production
it
(
'should send web-vitals'
,
async
()
=>
{
await
next
.
fetch
(
'/report-web-vitals'
)
let
eventsCount
=
0
const
browser
=
await
next
.
browser
(
'/report-web-vitals'
,
{
beforePageLoad
:
(
page
)
=>
{
page
.
route
(
'https://example.vercel.sh/vitals'
,
(
route
)
=>
{
eventsCount
+=
1
route
.
fulfill
()
})
},
})
// Refresh will trigger CLS and LCP. When page loads FCP and TTFB will trigger:
await
browser
.
refresh
()
// After interaction LCP and FID will trigger
await
browser
.
elementById
(
'btn'
).
click
()
// Make sure all registered events in performance-relayer has fired
await
check
(
async
()
=>
{
expect
(
eventsCount
).
toBeGreaterThanOrEqual
(
6
)
return
'success'
},
'success'
)
})
})
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