Files
vercel__next.js/test/e2e/app-dir/css-chunking/css-chunking.test.ts
Janka Uryga 4b048b6a55 test: fix missing await in css-chunking test (#96725)
`cheerio.each()` does not handle async things, so this was effectively
just a race
2026-08-05 16:06:49 +00:00

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')
}
}
)
})