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
3a41ddb5
Unverified
Commit
3a41ddb5
authored
May 10, 2020
by
Joe Haddad
Committed by
GitHub
May 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix check utility in tests (#12678)
parent
4c23bac3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
9 deletions
+5
-9
next-test-utils.js
test/lib/next-test-utils.js
+5
-9
No files found.
test/lib/next-test-utils.js
View file @
3a41ddb5
...
@@ -342,6 +342,7 @@ export async function startCleanStaticServer(dir) {
...
@@ -342,6 +342,7 @@ export async function startCleanStaticServer(dir) {
// 30 seconds
// 30 seconds
export
async
function
check
(
contentFn
,
regex
,
hardError
=
true
)
{
export
async
function
check
(
contentFn
,
regex
,
hardError
=
true
)
{
let
content
let
content
let
lastErr
for
(
let
tries
=
0
;
tries
<
30
;
tries
++
)
{
for
(
let
tries
=
0
;
tries
<
30
;
tries
++
)
{
try
{
try
{
...
@@ -352,19 +353,14 @@ export async function check(contentFn, regex, hardError = true) {
...
@@ -352,19 +353,14 @@ export async function check(contentFn, regex, hardError = true) {
}
}
await
waitFor
(
1000
)
await
waitFor
(
1000
)
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
tries
===
30
)
{
await
waitFor
(
1000
)
console
.
error
(
'Error while getting content'
,
{
regex
},
err
)
lastErr
=
err
}
}
}
}
}
console
.
error
(
'TIMED OUT CHECK: '
,
{
regex
,
content
})
console
.
error
(
'TIMED OUT CHECK: '
,
{
regex
,
content
,
lastErr
})
if
(
hardError
)
{
if
(
hardError
)
{
// maintain previous behavior where the error is thrown in a timeout
// and isn't caught when wrapped in a try/catch
setTimeout
(()
=>
{
throw
new
Error
(
'TIMED OUT: '
+
regex
+
'
\
n
\
n'
+
content
)
throw
new
Error
(
'TIMED OUT: '
+
regex
+
'
\
n
\
n'
+
content
)
},
1
)
}
}
return
false
return
false
}
}
...
...
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