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
68c3266a
Unverified
Commit
68c3266a
authored
Apr 20, 2020
by
Joe Haddad
Committed by
GitHub
Apr 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fast Refresh: Test Syntax Error Recovery (#12032)
parent
bc845f22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
ReactRefresh.test.js
test/acceptance/ReactRefresh.test.js
+54
-0
No files found.
test/acceptance/ReactRefresh.test.js
View file @
68c3266a
...
@@ -58,3 +58,57 @@ test('basic: can edit a component without losing state', async () => {
...
@@ -58,3 +58,57 @@ test('basic: can edit a component without losing state', async () => {
await
cleanup
()
await
cleanup
()
})
})
test
(
'can recover from a syntax error without losing state'
,
async
()
=>
{
const
[
session
,
cleanup
]
=
await
sandbox
()
await
session
.
patch
(
'index.js'
,
`
import { useCallback, useState } from 'react'
export default function Index() {
const [count, setCount] = useState(0)
const increment = useCallback(() => setCount(c => c + 1), [setCount])
return (
<main>
<p>{count}</p>
<button onClick={increment}>Increment</button>
</main>
)
}
`
)
await
session
.
evaluate
(()
=>
document
.
querySelector
(
'button'
).
click
())
expect
(
await
session
.
evaluate
(()
=>
document
.
querySelector
(
'p'
).
textContent
)
).
toBe
(
'1'
)
await
session
.
patch
(
'index.js'
,
`export default () => <div/`
)
expect
(
await
session
.
getOverlayContent
()).
toMatch
(
'Failed to compile'
)
await
session
.
patch
(
'index.js'
,
`
import { useCallback, useState } from 'react'
export default function Index() {
const [count, setCount] = useState(0)
const increment = useCallback(() => setCount(c => c + 1), [setCount])
return (
<main>
<p>Count: {count}</p>
<button onClick={increment}>Increment</button>
</main>
)
}
`
)
expect
(
await
session
.
evaluate
(()
=>
document
.
querySelector
(
'p'
).
textContent
)
).
toBe
(
'Count: 1'
)
await
cleanup
()
})
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