Files
vercel__next.js/test/e2e/app-dir/css-modules-data-urls/css-modules-data-urls.test.ts
Niklas Mischkulnig 0125959066 Turbopack: fix data-url CSS Module client references (#78428)
Closes #78114
Closes #78096
Closes PACK-4337

cc @jantimon . Thank you for creating the tests, that made it much easier!

They are indeed not working with Webpack at the moment:
```
data:text/css+module,.client{font-weight:700}
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> .client{font-weight:700}
```
2025-04-23 10:52:38 +02:00

50 lines
1.4 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
// CSS data urls are only support in Turbopack
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
'css-modules-data-urls',
() => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should apply rsc class name from data url correctly', async () => {
const browser = await next.browser('/')
const clientElementClass =
(await browser.elementByCss('#client').getAttribute('class')) || ''
expect(clientElementClass).not.toBe('')
})
it('should apply rsc styles from data url correctly', async () => {
const browser = await next.browser('/')
const rscElement = await browser
.elementByCss('#rsc')
.getComputedCss('font-weight')
expect(rscElement).toBe('700')
})
it('should apply client class name from data url correctly', async () => {
const browser = await next.browser('/')
const clientElementClass =
(await browser.elementByCss('#client').getAttribute('class')) || ''
expect(clientElementClass).not.toBe('')
})
it('should apply client styles from data url correctly', async () => {
const browser = await next.browser('/')
const clientElement = await browser
.elementByCss('#client')
.getComputedCss('font-weight')
expect(clientElement).toBe('700')
})
}
)