Skip to content

Commit

Permalink
Add test case for preloading buildManifest (vercel#16183)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored and Markus Lautenbach committed Aug 20, 2020
1 parent 57dff3d commit 959741c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/integration/dynamic-routing/test/index.test.js
Original file line number Diff line number Diff line change
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 959741c

Please sign in to comment.