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
873ac5db
Commit
873ac5db
authored
Sep 12, 2018
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for cache-control in development
parent
12c0c9fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
rendering.js
test/integration/basic/test/rendering.js
+40
-0
No files found.
test/integration/basic/test/rendering.js
View file @
873ac5db
/* global describe, test, it, expect */
/* global describe, test, it, expect */
import
cheerio
from
'cheerio'
import
cheerio
from
'cheerio'
import
{
BUILD_MANIFEST
,
REACT_LOADABLE_MANIFEST
}
from
'next/constants'
import
{
join
}
from
'path'
export
default
function
({
app
},
suiteName
,
render
,
fetch
,
appPort
)
{
export
default
function
({
app
},
suiteName
,
render
,
fetch
,
appPort
)
{
async
function
get
$
(
path
,
query
)
{
async
function
get
$
(
path
,
query
)
{
...
@@ -164,6 +166,44 @@ export default function ({ app }, suiteName, render, fetch, appPort) {
...
@@ -164,6 +166,44 @@ export default function ({ app }, suiteName, render, fetch, appPort) {
// Sourcemaps are applied by react-error-overlay, so we can't check them on SSR.
// Sourcemaps are applied by react-error-overlay, so we can't check them on SSR.
})
})
it
(
'should set Cache-Control header'
,
async
()
=>
{
const
buildId
=
'development'
// build dynamic page
await
fetch
(
'/dynamic/ssr'
)
const
buildManifest
=
require
(
join
(
'../.next'
,
BUILD_MANIFEST
))
console
.
log
(
buildManifest
)
const
reactLoadableManifest
=
require
(
join
(
'../.next'
,
REACT_LOADABLE_MANIFEST
))
const
resources
=
[]
// test a regular page
resources
.
push
(
`/_next/static/
${
buildId
}
/pages/index.js`
)
// test dynamic chunk
resources
.
push
(
'/_next/'
+
reactLoadableManifest
[
'../../components/hello1'
][
0
].
publicPath
)
// test main.js runtime etc
for
(
const
item
of
buildManifest
.
pages
[
'/dynamic/ssr'
])
{
resources
.
push
(
'/_next/'
+
item
)
}
for
(
const
item
of
buildManifest
.
devFiles
)
{
resources
.
push
(
'/_next/'
+
item
)
}
const
responses
=
await
Promise
.
all
(
resources
.
map
((
resource
)
=>
fetch
(
resource
)))
responses
.
forEach
((
res
)
=>
{
try
{
expect
(
res
.
headers
.
get
(
'Cache-Control'
)).
toBe
(
'no-store, must-revalidate'
)
}
catch
(
err
)
{
err
.
message
=
res
.
url
+
' '
+
err
.
message
throw
err
}
})
})
test
(
'asPath'
,
async
()
=>
{
test
(
'asPath'
,
async
()
=>
{
const
$
=
await
get
$
(
'/nav/as-path'
,
{
aa
:
10
})
const
$
=
await
get
$
(
'/nav/as-path'
,
{
aa
:
10
})
expect
(
$
(
'.as-path-content'
).
text
()).
toBe
(
'/nav/as-path?aa=10'
)
expect
(
$
(
'.as-path-content'
).
text
()).
toBe
(
'/nav/as-path?aa=10'
)
...
...
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