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
6b060d06
Commit
6b060d06
authored
Jan 23, 2026
by
Will Binns-Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
92a15b20
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
132 additions
and
1 deletion
+132
-1
eslint.config.mjs
eslint.config.mjs
+6
-1
layout.tsx
...e2e/app-dir/server-hmr-module-preservation/app/layout.tsx
+8
-0
page.tsx
test/e2e/app-dir/server-hmr-module-preservation/app/page.tsx
+13
-0
unmodified-module.ts
...r/server-hmr-module-preservation/app/unmodified-module.ts
+1
-0
next.config.js
...e2e/app-dir/server-hmr-module-preservation/next.config.js
+6
-0
server-hmr-module-preservation.test.ts
...odule-preservation/server-hmr-module-preservation.test.ts
+98
-0
No files found.
eslint.config.mjs
View file @
6b060d06
...
@@ -303,7 +303,12 @@ export default defineConfig([
...
@@ -303,7 +303,12 @@ export default defineConfig([
'jest/no-standalone-expect'
:
[
'jest/no-standalone-expect'
:
[
'error'
,
'error'
,
{
{
additionalTestBlockFunctions
:
[
'retry'
,
'itCI'
,
'itHeaded'
],
additionalTestBlockFunctions
:
[
'retry'
,
'itCI'
,
'itHeaded'
,
'itTurbopackDev'
,
],
},
},
],
],
},
},
...
...
test/e2e/app-dir/server-hmr-module-preservation/app/layout.tsx
0 → 100644
View file @
6b060d06
import
{
ReactNode
}
from
'react'
export
default
function
Root
({
children
}:
{
children
:
ReactNode
})
{
return
(
<
html
>
<
body
>
{
children
}
</
body
>
</
html
>
)
}
test/e2e/app-dir/server-hmr-module-preservation/app/page.tsx
0 → 100644
View file @
6b060d06
import
{
evaluatedAt
}
from
'./unmodified-module'
const
pageLoadId
=
Math
.
random
().
toString
(
36
).
slice
(
2
)
export
default
function
Page
()
{
return
(
<
div
>
<
p
id=
"greeting"
>
hello world
</
p
>
<
p
id=
"page-load-id"
>
Page Load ID:
{
pageLoadId
}
</
p
>
<
p
id=
"module-eval-time"
>
Module Evaluated At:
{
evaluatedAt
}
</
p
>
</
div
>
)
}
test/e2e/app-dir/server-hmr-module-preservation/app/unmodified-module.ts
0 → 100644
View file @
6b060d06
export
const
evaluatedAt
=
Date
.
now
()
test/e2e/app-dir/server-hmr-module-preservation/next.config.js
0 → 100644
View file @
6b060d06
/**
* @type {import('next').NextConfig}
*/
const
nextConfig
=
{}
module
.
exports
=
nextConfig
test/e2e/app-dir/server-hmr-module-preservation/server-hmr-module-preservation.test.ts
0 → 100644
View file @
6b060d06
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
retry
}
from
'next-test-utils'
describe
(
'server-hmr-module-preservation'
,
()
=>
{
const
{
next
,
isTurbopack
,
isNextDev
}
=
nextTestSetup
({
files
:
__dirname
,
startArgs
:
[
'--experimental-server-fast-refresh'
],
})
// Server HMR is a Turbopack-only feature, only available in dev mode
const
itTurbopackDev
=
isTurbopack
&&
isNextDev
?
it
:
it
.
skip
itTurbopackDev
(
'should preserve unmodified module when page module changes'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
// Wait for initial render with module timestamp
await
retry
(
async
()
=>
{
const
text
=
await
browser
.
elementByCss
(
'#module-eval-time'
).
text
()
expect
(
text
).
toMatch
(
/Module Evaluated At:
\d
+/
)
})
// Capture the initial module evaluation timestamp
const
initialModuleEvalTime
=
await
browser
.
elementByCss
(
'#module-eval-time'
)
.
text
()
// Mark where we are in CLI output
const
cliOutputBeforePatch
=
next
.
cliOutput
.
length
// Make a change to the page that doesn't affect the unmodified module
await
next
.
patchFile
(
'app/page.tsx'
,
(
content
)
=>
content
.
replace
(
'hello world'
,
'hello universe'
)
)
// Wait for HMR to apply and verify the page updated
await
retry
(
async
()
=>
{
const
text
=
await
browser
.
elementByCss
(
'#greeting'
).
text
()
expect
(
text
).
toBe
(
'hello universe'
)
})
// The unmodified module should NOT have been re-evaluated (same timestamp)
const
newModuleEvalTime
=
await
browser
.
elementByCss
(
'#module-eval-time'
)
.
text
()
expect
(
newModuleEvalTime
).
toBe
(
initialModuleEvalTime
)
// Also verify via CLI output that unmodified module wasn't re-evaluated
const
cliOutputAfterPatch
=
next
.
cliOutput
.
slice
(
cliOutputBeforePatch
)
expect
(
cliOutputAfterPatch
).
not
.
toContain
(
'[Module] evaluated'
)
}
)
itTurbopackDev
(
'should re-evaluate module when the module itself changes'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
// Wait for initial render
await
retry
(
async
()
=>
{
const
text
=
await
browser
.
elementByCss
(
'#module-eval-time'
).
text
()
expect
(
text
).
toMatch
(
/Module Evaluated At:
\d
+/
)
})
// Capture the initial module evaluation timestamp
const
initialModuleEvalTime
=
await
browser
.
elementByCss
(
'#module-eval-time'
)
.
text
()
// Mark CLI output position
const
cliOutputBeforePatch
=
next
.
cliOutput
.
length
// Make a change to the unmodified module itself
await
next
.
patchFile
(
'app/unmodified-module.ts'
,
(
content
)
=>
content
.
replace
(
"console.log('[Module] evaluated')"
,
"console.log('[Module] RE-evaluated')"
)
)
// Wait for HMR to apply - the module should be re-evaluated
// and the timestamp should change
await
retry
(
async
()
=>
{
// Refresh to trigger re-evaluation of changed modules
await
browser
.
refresh
()
const
newModuleEvalTime
=
await
browser
.
elementByCss
(
'#module-eval-time'
)
.
text
()
expect
(
newModuleEvalTime
).
not
.
toBe
(
initialModuleEvalTime
)
})
// Verify via CLI output that module was re-evaluated
const
cliOutputAfterPatch
=
next
.
cliOutput
.
slice
(
cliOutputBeforePatch
)
expect
(
cliOutputAfterPatch
).
toContain
(
'[Module] RE-evaluated'
)
}
)
})
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