mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
8b7b6fea86
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.
75 lines
2.1 KiB
TypeScript
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}"`)
|
|
})
|
|
}
|
|
)
|