Skip to content

Commit dbb19c5

Browse files
authored
[test] Remove describeVariants helper (#76631)
1 parent b84952f commit dbb19c5

File tree

3 files changed

+32
-68
lines changed

3 files changed

+32
-68
lines changed

test/development/app-dir/basic/basic.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { nextTestSetup } from 'e2e-utils'
2-
import { describeVariants as describe, waitFor } from 'next-test-utils'
2+
import { waitFor } from 'next-test-utils'
33
import { createSandbox, waitForHydration } from 'development-sandbox'
44

5-
describe.each(['default', 'turbo'])('basic app-dir tests', () => {
5+
describe('basic app-dir tests', () => {
66
const { next } = nextTestSetup({
77
files: __dirname,
88
})
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,39 @@
11
import { nextTestSetup } from 'e2e-utils'
2-
import { describeVariants } from 'next-test-utils'
32

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+
})
1912

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')
3217

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 {
3725
// We remove hash from the class name in test mode using env var because it is not deterministic.
3826
expect($('p').attr('class')).toBe('search-keyword style-module__blue')
39-
})
27+
}
28+
})
4029

41-
it('should support browserslist', async () => {
42-
const $ = await next.browser('/')
30+
it('should support browserslist', async () => {
31+
const $ = await next.browser('/')
4332

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+
)
5137
})
52-
}
53-
)
38+
})
39+
})

test/lib/next-test-utils.ts

-22
Original file line numberDiff line numberDiff line change
@@ -1520,28 +1520,6 @@ export function getUrlFromBackgroundImage(backgroundImage: string) {
15201520
return matches
15211521
}
15221522

1523-
/**
1524-
* For better editor support, pass in the variants this should run on (`default` and/or `turbo`) as cases.
1525-
*
1526-
* This is necessary if separate snapshots are needed for next.js with webpack vs turbopack.
1527-
*/
1528-
export const describeVariants = {
1529-
each(variants: TestVariants[]) {
1530-
return (name: string, fn: (variants: TestVariants) => any) => {
1531-
if (
1532-
!Array.isArray(variants) ||
1533-
!variants.every((val) => typeof val === 'string')
1534-
) {
1535-
throw new Error('variants need to be an array of strings')
1536-
}
1537-
1538-
for (const variant of variants) {
1539-
getSnapshotTestDescribe(variant).each([variant])(name, fn)
1540-
}
1541-
}
1542-
},
1543-
}
1544-
15451523
export const getTitle = (browser: BrowserInterface) =>
15461524
browser.elementByCss('title').text()
15471525

0 commit comments

Comments
 (0)