Add test case for preloading buildManifest (#16183)

This commit is contained in:
JJ Kasper 2020-08-13 23:04:27 -05:00 committed by GitHub
parent 4e813ae0c6
commit 39e00a3f2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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, '/')