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
c3f11c20
Unverified
Commit
c3f11c20
authored
Feb 24, 2020
by
Joe Haddad
Committed by
GitHub
Feb 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Nested Catch-All Coverage (#10659)
* Improve Nested Catch-All Coverage * use check
parent
51b35f1f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
15 deletions
+48
-15
[...slug].js
test/integration/prerender/pages/catchall/[...slug].js
+1
-1
index.test.js
test/integration/prerender/test/index.test.js
+47
-14
No files found.
test/integration/prerender/pages/catchall/[...slug].js
View file @
c3f11c20
...
@@ -29,5 +29,5 @@ export default ({ slug }) => {
...
@@ -29,5 +29,5 @@ export default ({ slug }) => {
if
(
isFallback
)
{
if
(
isFallback
)
{
return
<
p
id
=
"catchall"
>
fallback
<
/p
>
return
<
p
id
=
"catchall"
>
fallback
<
/p
>
}
}
return
<
p
id
=
"catchall"
>
Hi
{
slug
.
join
(
'
/
'
)}
<
/p
>
return
<
p
id
=
"catchall"
>
Hi
{
slug
.
join
(
'
'
)}
<
/p
>
}
}
test/integration/prerender/test/index.test.js
View file @
c3f11c20
/* eslint-env jest */
/* eslint-env jest */
/* global jasmine */
/* global jasmine */
import
fs
from
'fs-extra'
import
{
join
,
dirname
}
from
'path'
import
cheerio
from
'cheerio'
import
cheerio
from
'cheerio'
import
webdriver
from
'next-webdriver'
import
escapeRegex
from
'escape-string-regexp'
import
escapeRegex
from
'escape-string-regexp'
import
fs
from
'fs-extra'
import
{
import
{
renderViaHTTP
,
check
,
fetchViaHTTP
,
fetchViaHTTP
,
findPort
,
findPort
,
launchApp
,
getReactErrorOverlayContent
,
initNextServerScript
,
killApp
,
killApp
,
waitFor
,
launchApp
,
nextBuild
,
nextBuild
,
nextStart
,
stopApp
,
nextExport
,
nextExport
,
nextStart
,
normalizeRegEx
,
normalizeRegEx
,
renderViaHTTP
,
startStaticServer
,
startStaticServer
,
initNextServerScript
,
stopApp
,
getReactErrorOverlayContent
,
waitFor
,
}
from
'next-test-utils'
}
from
'next-test-utils'
import
webdriver
from
'next-webdriver'
import
{
dirname
,
join
}
from
'path'
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
const
appDir
=
join
(
__dirname
,
'..'
)
const
appDir
=
join
(
__dirname
,
'..'
)
...
@@ -376,7 +377,7 @@ const runTests = (dev = false, looseMode = false) => {
...
@@ -376,7 +377,7 @@ const runTests = (dev = false, looseMode = false) => {
.
text
()
.
text
()
).
isFallback
).
isFallback
).
toBe
(
false
)
).
toBe
(
false
)
expect
(
$
(
'#catchall'
).
text
()).
toMatch
(
/Hi.*
?
another
\/
value/
)
expect
(
$
(
'#catchall'
).
text
()).
toMatch
(
/Hi.*
?
another
value/
)
})
})
it
(
'should support lazy catchall route'
,
async
()
=>
{
it
(
'should support lazy catchall route'
,
async
()
=>
{
...
@@ -398,10 +399,42 @@ const runTests = (dev = false, looseMode = false) => {
...
@@ -398,10 +399,42 @@ const runTests = (dev = false, looseMode = false) => {
const
text1
=
await
browser
.
elementByCss
(
'#catchall'
).
text
()
const
text1
=
await
browser
.
elementByCss
(
'#catchall'
).
text
()
expect
(
text1
).
toBe
(
'fallback'
)
expect
(
text1
).
toBe
(
'fallback'
)
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
4000
))
await
check
(
()
=>
browser
.
elementByCss
(
'#catchall'
).
text
(),
/Hi.*
?
delayby3s/
)
}
})
it
(
'should support nested lazy catchall route'
,
async
()
=>
{
// Dev doesn't support fallback yet
if
(
dev
)
{
const
html
=
await
renderViaHTTP
(
appPort
,
'/catchall/notreturnedinpaths/nested'
)
const
$
=
cheerio
.
load
(
html
)
expect
(
$
(
'#catchall'
).
text
()).
toMatch
(
/Hi.*
?
notreturnedinpaths nested/
)
}
// Production will render fallback for a "lazy" route
else
{
const
html
=
await
renderViaHTTP
(
appPort
,
'/catchall/notreturnedinpaths/nested'
)
const
$
=
cheerio
.
load
(
html
)
expect
(
$
(
'#catchall'
).
text
()).
toBe
(
'fallback'
)
// hydration
const
browser
=
await
webdriver
(
appPort
,
'/catchall/delayby3s/nested'
)
const
text2
=
await
browser
.
elementByCss
(
'#catchall'
).
text
()
const
text1
=
await
browser
.
elementByCss
(
'#catchall'
).
text
()
expect
(
text2
).
toMatch
(
/Hi.*
?
delayby3s/
)
expect
(
text1
).
toBe
(
'fallback'
)
await
check
(
()
=>
browser
.
elementByCss
(
'#catchall'
).
text
(),
/Hi.*
?
delayby3s nested/
)
}
}
})
})
...
...
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