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
139bc40f
Unverified
Commit
139bc40f
authored
Sep 25, 2018
by
Tim Neutkens
Committed by
GitHub
Sep 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More reliable error-recovery tests (#5281)
As they were failing intermittently, this PR tries to solve that.
parent
bb06f507
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
47 deletions
+7
-47
error-recovery.js
test/integration/basic/test/error-recovery.js
+5
-47
next-test-utils.js
test/lib/next-test-utils.js
+2
-0
No files found.
test/integration/basic/test/error-recovery.js
View file @
139bc40f
/* global describe, it, expect */
import
webdriver
from
'next-webdriver'
import
{
join
}
from
'path'
import
{
check
,
File
,
waitFor
,
getReactErrorOverlayContent
}
from
'next-test-utils'
import
{
check
,
File
,
getReactErrorOverlayContent
}
from
'next-test-utils'
export
default
(
context
,
render
)
=>
{
describe
(
'Error Recovery'
,
()
=>
{
...
...
@@ -13,9 +13,6 @@ export default (context, render) => {
try
{
browser
=
await
webdriver
(
context
.
appPort
,
'/hmr/about'
)
// Wait for react-error-overlay
await
browser
.
waitForElementByCss
(
'iframe'
,
2000
)
// react-error-overlay uses the following inline style if an editorHandler is installed
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/style="cursor: pointer;"/
)
...
...
@@ -45,8 +42,6 @@ export default (context, render) => {
aboutPage
.
replace
(
'</div>'
,
'div'
)
await
waitFor
(
10000
)
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/Unterminated JSX contents/
)
aboutPage
.
restore
()
...
...
@@ -64,34 +59,6 @@ export default (context, render) => {
}
})
it
(
'should not show the default HMR error overlay'
,
async
()
=>
{
let
browser
const
aboutPage
=
new
File
(
join
(
__dirname
,
'../'
,
'pages'
,
'hmr'
,
'about.js'
))
try
{
browser
=
await
webdriver
(
context
.
appPort
,
'/hmr/about'
)
const
text
=
await
browser
.
elementByCss
(
'p'
).
text
()
expect
(
text
).
toBe
(
'This is the about page.'
)
aboutPage
.
replace
(
'</div>'
,
'div'
)
await
waitFor
(
10000
)
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/Unterminated JSX contents/
)
await
waitFor
(
10000
)
// Check for the error overlay
const
bodyHtml
=
await
browser
.
elementByCss
(
'body'
).
getAttribute
(
'innerHTML'
)
expect
(
bodyHtml
.
includes
(
'webpack-hot-middleware-clientOverlay'
)).
toBeFalsy
()
}
finally
{
aboutPage
.
restore
()
if
(
browser
)
{
browser
.
close
()
}
}
})
it
(
'should show the error on all pages'
,
async
()
=>
{
const
aboutPage
=
new
File
(
join
(
__dirname
,
'../'
,
'pages'
,
'hmr'
,
'about.js'
))
let
browser
...
...
@@ -100,8 +67,6 @@ export default (context, render) => {
browser
=
await
webdriver
(
context
.
appPort
,
'/hmr/contact'
)
await
waitFor
(
10000
)
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/Unterminated JSX contents/
)
aboutPage
.
restore
()
...
...
@@ -129,8 +94,6 @@ export default (context, render) => {
aboutPage
.
replace
(
'export'
,
'aa=20;
\
nexport'
)
await
waitFor
(
10000
)
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/aa is not defined/
)
aboutPage
.
restore
()
...
...
@@ -156,8 +119,6 @@ export default (context, render) => {
const
aboutPage
=
new
File
(
join
(
__dirname
,
'../'
,
'pages'
,
'hmr'
,
'about.js'
))
aboutPage
.
replace
(
'return'
,
'throw new Error("an-expected-error");
\
nreturn'
)
await
waitFor
(
10000
)
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/an-expected-error/
)
aboutPage
.
restore
()
...
...
@@ -179,9 +140,10 @@ export default (context, render) => {
const
aboutPage
=
new
File
(
join
(
__dirname
,
'../'
,
'pages'
,
'hmr'
,
'about.js'
))
aboutPage
.
replace
(
'export default'
,
'export default "not-a-page"
\
nexport const fn = '
)
await
waitFor
(
10000
)
expect
(
await
browser
.
elementByCss
(
'body'
).
text
()).
toMatch
(
/The default export is not a React Component/
)
await
check
(
()
=>
browser
.
elementByCss
(
'body'
).
text
(),
/The default export is not a React Component/
)
aboutPage
.
restore
()
...
...
@@ -221,8 +183,6 @@ export default (context, render) => {
const
browser
=
await
webdriver
(
context
.
appPort
,
'/hmr'
)
await
browser
.
elementByCss
(
'#error-in-gip-link'
).
click
()
await
waitFor
(
10000
)
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/an-expected-error-in-gip/
)
const
erroredPage
=
new
File
(
join
(
__dirname
,
'../'
,
'pages'
,
'hmr'
,
'error-in-gip.js'
))
...
...
@@ -240,8 +200,6 @@ export default (context, render) => {
it
(
'should recover after an error reported via SSR'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
appPort
,
'/hmr/error-in-gip'
)
await
waitFor
(
10000
)
expect
(
await
getReactErrorOverlayContent
(
browser
)).
toMatch
(
/an-expected-error-in-gip/
)
const
erroredPage
=
new
File
(
join
(
__dirname
,
'../'
,
'pages'
,
'hmr'
,
'error-in-gip.js'
))
...
...
test/lib/next-test-utils.js
View file @
139bc40f
...
...
@@ -216,6 +216,8 @@ export async function getReactErrorOverlayContent (browser) {
},
1000
*
30
)
while
(
!
found
)
{
try
{
await
browser
.
waitForElementByCss
(
'iframe'
,
10000
)
const
hasIframe
=
await
browser
.
hasElementByCssSelector
(
'iframe'
)
if
(
!
hasIframe
)
{
throw
new
Error
(
'Waiting for iframe'
)
...
...
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