|
1 | 1 | import { nextTestSetup } from 'e2e-utils'
|
2 |
| -import { describeVariants } from 'next-test-utils' |
3 | 2 |
|
4 |
| -describeVariants.each(['turbo'])('experimental-lightningcss', () => { |
5 |
| - const { next } = nextTestSetup({ |
6 |
| - files: __dirname, |
7 |
| - }) |
8 |
| - |
9 |
| - it('should support css modules', async () => { |
10 |
| - // Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API. |
11 |
| - const $ = await next.render$('/') |
12 |
| - expect($('p').text()).toBe('hello world') |
13 |
| - // swc_css does not include `-module` in the class name, while lightningcss does. |
14 |
| - expect($('p').attr('class')).toBe( |
15 |
| - 'search-keyword style-module__hlQ3RG__blue' |
16 |
| - ) |
17 |
| - }) |
18 |
| -}) |
| 3 | +describe('experimental-lightningcss with default mode', () => { |
| 4 | + describe('in dev server', () => { |
| 5 | + const { isTurbopack, next } = nextTestSetup({ |
| 6 | + files: __dirname, |
| 7 | + dependencies: { lightningcss: '^1.23.0' }, |
| 8 | + packageJson: { |
| 9 | + browserslist: ['chrome 100'], |
| 10 | + }, |
| 11 | + }) |
19 | 12 |
|
20 |
| -// lightningcss produces different class names in turbo mode |
21 |
| -describeVariants.each(['default'])( |
22 |
| - 'experimental-lightningcss with default mode', |
23 |
| - () => { |
24 |
| - describe('in dev server', () => { |
25 |
| - const { next } = nextTestSetup({ |
26 |
| - files: __dirname, |
27 |
| - dependencies: { lightningcss: '^1.23.0' }, |
28 |
| - packageJson: { |
29 |
| - browserslist: ['chrome 100'], |
30 |
| - }, |
31 |
| - }) |
| 13 | + it('should support css modules', async () => { |
| 14 | + // Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API. |
| 15 | + const $ = await next.render$('/') |
| 16 | + expect($('p').text()).toBe('hello world') |
32 | 17 |
|
33 |
| - it('should support css modules', async () => { |
34 |
| - // Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API. |
35 |
| - const $ = await next.render$('/') |
36 |
| - expect($('p').text()).toBe('hello world') |
| 18 | + // lightningcss produces different class names in turbo mode |
| 19 | + if (isTurbopack) { |
| 20 | + // swc_css does not include `-module` in the class name, while lightningcss does. |
| 21 | + expect($('p').attr('class')).toBe( |
| 22 | + 'search-keyword style-module__hlQ3RG__blue' |
| 23 | + ) |
| 24 | + } else { |
37 | 25 | // We remove hash from the class name in test mode using env var because it is not deterministic.
|
38 | 26 | expect($('p').attr('class')).toBe('search-keyword style-module__blue')
|
39 |
| - }) |
| 27 | + } |
| 28 | + }) |
40 | 29 |
|
41 |
| - it('should support browserslist', async () => { |
42 |
| - const $ = await next.browser('/') |
| 30 | + it('should support browserslist', async () => { |
| 31 | + const $ = await next.browser('/') |
43 | 32 |
|
44 |
| - expect(await $.elementByCss('.nested').text()).toBe( |
45 |
| - 'Red due to nesting' |
46 |
| - ) |
47 |
| - expect(await $.elementByCss('.nested').getComputedCss('color')).toBe( |
48 |
| - 'rgb(255, 0, 0)' |
49 |
| - ) |
50 |
| - }) |
| 33 | + expect(await $.elementByCss('.nested').text()).toBe('Red due to nesting') |
| 34 | + expect(await $.elementByCss('.nested').getComputedCss('color')).toBe( |
| 35 | + 'rgb(255, 0, 0)' |
| 36 | + ) |
51 | 37 | })
|
52 |
| - } |
53 |
| -) |
| 38 | + }) |
| 39 | +}) |
0 commit comments