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
b72d9fa4
Unverified
Commit
b72d9fa4
authored
May 05, 2020
by
JJ Kasper
Committed by
GitHub
May 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests to poll for output instead of wait for it (#12534)
parent
8fd7338f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
29 deletions
+38
-29
index.test.js
test/integration/jsconfig-baseurl/test/index.test.js
+7
-5
index.test.js
test/integration/jsconfig-paths/test/index.test.js
+7
-3
next-test-utils.js
test/lib/next-test-utils.js
+24
-21
No files found.
test/integration/jsconfig-baseurl/test/index.test.js
View file @
b72d9fa4
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
findPort
,
findPort
,
launchApp
,
launchApp
,
killApp
,
killApp
,
waitFor
,
check
,
}
from
'next-test-utils'
}
from
'next-test-utils'
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
...
@@ -54,11 +54,13 @@ describe('TypeScript Features', () => {
...
@@ -54,11 +54,13 @@ describe('TypeScript Features', () => {
)
)
await
renderViaHTTP
(
appPort
,
'/hello'
)
await
renderViaHTTP
(
appPort
,
'/hello'
)
await
waitFor
(
2
*
1000
)
const
found
=
await
check
(
await
fs
.
writeFile
(
basicPage
,
contents
)
()
=>
output
,
expect
(
output
).
toContain
(
/Module not found: Can't resolve 'components
\/
worldd' in/
,
`Module not found: Can't resolve 'components/worldd' in`
false
)
)
await
fs
.
writeFile
(
basicPage
,
contents
)
expect
(
found
).
toBe
(
true
)
})
})
})
})
})
})
test/integration/jsconfig-paths/test/index.test.js
View file @
b72d9fa4
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
findPort
,
findPort
,
launchApp
,
launchApp
,
killApp
,
killApp
,
waitFor
,
check
,
}
from
'next-test-utils'
}
from
'next-test-utils'
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
...
@@ -71,9 +71,13 @@ describe('TypeScript Features', () => {
...
@@ -71,9 +71,13 @@ describe('TypeScript Features', () => {
await
fs
.
writeFile
(
basicPage
,
contents
.
replace
(
'@c/world'
,
'@c/worldd'
))
await
fs
.
writeFile
(
basicPage
,
contents
.
replace
(
'@c/world'
,
'@c/worldd'
))
await
renderViaHTTP
(
appPort
,
'/basic-alias'
)
await
renderViaHTTP
(
appPort
,
'/basic-alias'
)
await
waitFor
(
2
*
1000
)
const
found
=
await
check
(
()
=>
output
,
/Module not found: Can't resolve '@c
\/
worldd' in/
,
false
)
await
fs
.
writeFile
(
basicPage
,
contents
)
await
fs
.
writeFile
(
basicPage
,
contents
)
expect
(
output
).
toContain
(
`Module not found: Can't resolve '@c/worldd' in`
)
expect
(
found
).
toBe
(
true
)
})
})
})
})
})
})
test/lib/next-test-utils.js
View file @
b72d9fa4
...
@@ -338,32 +338,35 @@ export async function startCleanStaticServer(dir) {
...
@@ -338,32 +338,35 @@ export async function startCleanStaticServer(dir) {
return
server
return
server
}
}
export
async
function
check
(
contentFn
,
regex
)
{
// check for content in 1 second intervals timing out after
let
found
=
false
// 30 seconds
const
timeout
=
setTimeout
(
async
()
=>
{
export
async
function
check
(
contentFn
,
regex
,
hardError
=
true
)
{
if
(
found
)
{
let
content
return
}
for
(
let
tries
=
0
;
tries
<
30
;
tries
++
)
{
let
content
try
{
try
{
content
=
await
contentFn
()
content
=
await
contentFn
()
}
catch
(
err
)
{
if
(
regex
.
test
(
content
))
{
console
.
error
(
'Error while getting content'
,
{
regex
})
// found the content
}
return
true
console
.
error
(
'TIMED OUT CHECK: '
,
{
regex
,
content
})
throw
new
Error
(
'TIMED OUT: '
+
regex
+
'
\
n
\
n'
+
content
)
},
1000
*
30
)
while
(
!
found
)
{
try
{
const
newContent
=
await
contentFn
()
if
(
regex
.
test
(
newContent
))
{
found
=
true
clearTimeout
(
timeout
)
break
}
}
await
waitFor
(
1000
)
await
waitFor
(
1000
)
}
catch
(
ex
)
{}
}
catch
(
err
)
{
if
(
tries
===
30
)
{
console
.
error
(
'Error while getting content'
,
{
regex
},
err
)
}
}
}
console
.
error
(
'TIMED OUT CHECK: '
,
{
regex
,
content
})
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
)
},
1
)
}
}
return
false
}
}
export
class
File
{
export
class
File
{
...
...
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