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
f07f69dd
Unverified
Commit
f07f69dd
authored
Dec 21, 2022
by
Jan Kaifer
Committed by
GitHub
Dec 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test checking that repeated edits won't cause hydration issues (#44189)
parent
6713ce4c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
index.tsx
test/development/repeated-dev-edits/pages/index.tsx
+3
-0
repeated-dev-edits.test.ts
...development/repeated-dev-edits/repeated-dev-edits.test.ts
+48
-0
No files found.
test/development/repeated-dev-edits/pages/index.tsx
0 → 100644
View file @
f07f69dd
export
default
function
Page
()
{
return
<
p
id=
"version-1"
>
version-1
</
p
>
}
test/development/repeated-dev-edits/repeated-dev-edits.test.ts
0 → 100644
View file @
f07f69dd
import
{
createNextDescribe
}
from
'e2e-utils'
import
fs
from
'fs-extra'
import
{
hasRedbox
}
from
'next-test-utils'
import
path
from
'path'
createNextDescribe
(
'repeated-dev-edits'
,
{
files
:
__dirname
,
},
({
next
})
=>
{
// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API.
it
(
'should not break the hydration '
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'version-1'
)
const
pagePath
=
'pages/index.tsx'
const
pageContent
=
String
(
await
fs
.
readFile
(
path
.
join
(
__dirname
,
pagePath
))
)
await
next
.
patchFile
(
pagePath
,
pageContent
.
replaceAll
(
'version-1'
,
'version-2'
)
)
browser
.
waitForElementByCss
(
'#version-2'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'version-2'
)
// Verify no hydration mismatch:
expect
(
await
hasRedbox
(
browser
)).
toBeFalse
()
await
next
.
patchFile
(
pagePath
,
pageContent
.
replaceAll
(
'version-1'
,
'version-3'
)
)
browser
.
waitForElementByCss
(
'#version-3'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'version-3'
)
// Verify no hydration mismatch:
expect
(
await
hasRedbox
(
browser
)).
toBeFalse
()
browser
.
refresh
()
// Verify no hydration mismatch:
expect
(
await
hasRedbox
(
browser
)).
toBeFalse
()
})
}
)
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