Skip to content

Commit

Permalink
Add test case for preloading buildManifest (#16183)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Aug 14, 2020
1 parent 4e813ae commit 39e00a3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/integration/dynamic-routing/test/index.test.js
Expand Up @@ -561,6 +561,40 @@ function runTests(dev) {
expect(res.status).toBe(400)
})

it('should preload buildManifest for auto-export dynamic pages', async () => {
const html = await renderViaHTTP(appPort, '/on-mount/hello')
const $ = cheerio.load(html)
let found = 0

for (const el of Array.from($('link[rel="preload"]'))) {
const { href } = el.attribs
if (
href.includes('_buildManifest.js') ||
href.includes('_buildManifest.module.js')
) {
found++
}
}
expect(found).toBe(dev ? 2 : 1)
})

it('should not preload buildManifest for non-auto export dynamic pages', async () => {
const html = await renderViaHTTP(appPort, '/hello')
const $ = cheerio.load(html)
let found = 0

for (const el of Array.from($('link[rel="preload"]'))) {
const { href } = el.attribs
if (
href.includes('_buildManifest.js') ||
href.includes('_buildManifest.module.js')
) {
found++
}
}
expect(found).toBe(0)
})

if (dev) {
it('should resolve dynamic route href for page added later', async () => {
const browser = await webdriver(appPort, '/')
Expand Down

0 comments on commit 39e00a3

Please sign in to comment.