next.js/test/e2e/app-dir/css-chunking/css-chunking.test.ts
css-chunking.test.ts26 lines890 B
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"]')
      stylesheets.each(async (_, element) => {
        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')
      })
    }
  )
})
Quest for Codev2.0.0
/
SIGN IN