mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
4b048b6a55
`cheerio.each()` does not handle async things, so this was effectively just a race
26 lines
911 B
TypeScript
26 lines
911 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('css-chunking', () => {
|
|
const { next } = nextTestSetup({ files: __dirname })
|
|
|
|
// this test asserts that all the emitted CSS files for the index page
|
|
// do not contain styles for the `/other` page, which can happen
|
|
// when the CSSChunkingPlugin is enabled and styles are shared across
|
|
// both routes.
|
|
;(process.env.IS_TURBOPACK_TEST ? it.skip : it)(
|
|
'should be possible to disable the chunking plugin',
|
|
async () => {
|
|
const $ = await next.render$('/')
|
|
const stylesheets = $('link[rel="stylesheet"]')
|
|
for (const element of stylesheets.get() as CheerioElement[]) {
|
|
const href = element.attribs.href
|
|
const result = await next.fetch(href)
|
|
const css = await result.text()
|
|
|
|
// eslint-disable-next-line jest/no-standalone-expect
|
|
expect(css).not.toContain('.otherPage')
|
|
}
|
|
}
|
|
)
|
|
})
|