Files
vercel__next.js/test/production/css-features/css-features.test.ts
Will Binns-Smith 8b7b6fea86 Turbopack tests: remove assertions that duplicate webpack results (#95688)
We forked test assertions in places in the early days of merging
Turbopack. Now that we more closely align, a bunch of these had the
exact same assertions. Fold them into one.
2026-07-10 12:11:26 -07:00

75 lines
2.1 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import { join } from 'path'
describe('Custom Properties: Pass-Through IE11', () => {
const { next } = nextTestSetup({
files: join(__dirname, 'fixtures', 'cp-ie-11'),
})
it(`should've emitted a single CSS file`, async () => {
const $ = await next.render$('/')
const cssSheet = $('link[rel="stylesheet"]')
expect(cssSheet.length).toBe(1)
const stylesheet = cssSheet.attr('href')!
const cssContent = (await next.fetch(stylesheet).then((res) => res.text()))
.replace(/\/\*.*?\*\//g, '')
.trim()
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`":root{--color:red}h1{color:var(--color)}"`
)
})
})
describe('Custom Properties: Pass-Through Modern', () => {
const { next } = nextTestSetup({
files: join(__dirname, 'fixtures', 'cp-modern'),
})
it(`should've emitted a single CSS file`, async () => {
const $ = await next.render$('/')
const cssSheet = $('link[rel="stylesheet"]')
expect(cssSheet.length).toBe(1)
const stylesheet = cssSheet.attr('href')!
const cssContent = (await next.fetch(stylesheet).then((res) => res.text()))
.replace(/\/\*.*?\*\//g, '')
.trim()
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`":root{--color:red}h1{color:var(--color)}"`
)
})
})
// Invalid CSS that Lightning CSS in Turbopack interprets differently.
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'Inline Comments: Minify',
() => {
const { next } = nextTestSetup({
files: join(__dirname, 'fixtures', 'inline-comments'),
})
it(`should've emitted a single CSS file`, async () => {
const $ = await next.render$('/')
const cssSheet = $('link[rel="stylesheet"]')
expect(cssSheet.length).toBe(1)
const stylesheet = cssSheet.attr('href')!
const cssContent = (
await next.fetch(stylesheet).then((res) => res.text())
)
.replace(/\/\*.*?\*\//g, '')
.trim()
expect(
cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`"*{box-sizing:border-box}"`)
})
}
)