Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
dbb19c55
Unverified
Commit
dbb19c55
authored
Mar 03, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Mar 03, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Remove `describeVariants` helper (#76631)
parent
b84952f0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
68 deletions
+32
-68
basic.test.ts
test/development/app-dir/basic/basic.test.ts
+2
-2
experimental-lightningcss.test.ts
...perimental-lightningcss/experimental-lightningcss.test.ts
+30
-44
next-test-utils.ts
test/lib/next-test-utils.ts
+0
-22
No files found.
test/development/app-dir/basic/basic.test.ts
View file @
dbb19c55
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
describeVariants
as
describe
,
waitFor
}
from
'next-test-utils'
import
{
waitFor
}
from
'next-test-utils'
import
{
createSandbox
,
waitForHydration
}
from
'development-sandbox'
import
{
createSandbox
,
waitForHydration
}
from
'development-sandbox'
describe
.
each
([
'default'
,
'turbo'
])
(
'basic app-dir tests'
,
()
=>
{
describe
(
'basic app-dir tests'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
...
test/development/app-dir/experimental-lightningcss/experimental-lightningcss.test.ts
View file @
dbb19c55
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
describeVariants
}
from
'next-test-utils'
describeVariants
.
each
([
'turbo'
])(
'experimental-lightningcss'
,
()
=>
{
describe
(
'experimental-lightningcss with default mode'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
describe
(
'in dev server'
,
()
=>
{
files
:
__dirname
,
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
})
files
:
__dirname
,
dependencies
:
{
lightningcss
:
'^1.23.0'
},
it
(
'should support css modules'
,
async
()
=>
{
packageJson
:
{
// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API.
browserslist
:
[
'chrome 100'
],
const
$
=
await
next
.
render$
(
'/'
)
},
expect
(
$
(
'p'
).
text
()).
toBe
(
'hello world'
)
})
// swc_css does not include `-module` in the class name, while lightningcss does.
expect
(
$
(
'p'
).
attr
(
'class'
)).
toBe
(
'search-keyword style-module__hlQ3RG__blue'
)
})
})
// lightningcss produces different class names in turbo mode
it
(
'should support css modules'
,
async
()
=>
{
describeVariants
.
each
([
'default'
])(
// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API.
'experimental-lightningcss with default mode'
,
const
$
=
await
next
.
render$
(
'/'
)
()
=>
{
expect
(
$
(
'p'
).
text
()).
toBe
(
'hello world'
)
describe
(
'in dev server'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
dependencies
:
{
lightningcss
:
'^1.23.0'
},
packageJson
:
{
browserslist
:
[
'chrome 100'
],
},
})
it
(
'should support css modules'
,
async
()
=>
{
// lightningcss produces different class names in turbo mode
// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API.
if
(
isTurbopack
)
{
const
$
=
await
next
.
render$
(
'/'
)
// swc_css does not include `-module` in the class name, while lightningcss does.
expect
(
$
(
'p'
).
text
()).
toBe
(
'hello world'
)
expect
(
$
(
'p'
).
attr
(
'class'
)).
toBe
(
'search-keyword style-module__hlQ3RG__blue'
)
}
else
{
// We remove hash from the class name in test mode using env var because it is not deterministic.
// We remove hash from the class name in test mode using env var because it is not deterministic.
expect
(
$
(
'p'
).
attr
(
'class'
)).
toBe
(
'search-keyword style-module__blue'
)
expect
(
$
(
'p'
).
attr
(
'class'
)).
toBe
(
'search-keyword style-module__blue'
)
})
}
})
it
(
'should support browserslist'
,
async
()
=>
{
it
(
'should support browserslist'
,
async
()
=>
{
const
$
=
await
next
.
browser
(
'/'
)
const
$
=
await
next
.
browser
(
'/'
)
expect
(
await
$
.
elementByCss
(
'.nested'
).
text
()).
toBe
(
expect
(
await
$
.
elementByCss
(
'.nested'
).
text
()).
toBe
(
'Red due to nesting'
)
'Red due to nesting'
expect
(
await
$
.
elementByCss
(
'.nested'
).
getComputedCss
(
'color'
)).
toBe
(
)
'rgb(255, 0, 0)'
expect
(
await
$
.
elementByCss
(
'.nested'
).
getComputedCss
(
'color'
)).
toBe
(
)
'rgb(255, 0, 0)'
)
})
})
})
}
}
)
)
}
)
test/lib/next-test-utils.ts
View file @
dbb19c55
...
@@ -1520,28 +1520,6 @@ export function getUrlFromBackgroundImage(backgroundImage: string) {
...
@@ -1520,28 +1520,6 @@ export function getUrlFromBackgroundImage(backgroundImage: string) {
return
matches
return
matches
}
}
/**
* For better editor support, pass in the variants this should run on (`default` and/or `turbo`) as cases.
*
* This is necessary if separate snapshots are needed for next.js with webpack vs turbopack.
*/
export
const
describeVariants
=
{
each
(
variants
:
TestVariants
[])
{
return
(
name
:
string
,
fn
:
(
variants
:
TestVariants
)
=>
any
)
=>
{
if
(
!
Array
.
isArray
(
variants
)
||
!
variants
.
every
((
val
)
=>
typeof
val
===
'string'
)
)
{
throw
new
Error
(
'variants need to be an array of strings'
)
}
for
(
const
variant
of
variants
)
{
getSnapshotTestDescribe
(
variant
).
each
([
variant
])(
name
,
fn
)
}
}
},
}
export
const
getTitle
=
(
browser
:
BrowserInterface
)
=>
export
const
getTitle
=
(
browser
:
BrowserInterface
)
=>
browser
.
elementByCss
(
'title'
).
text
()
browser
.
elementByCss
(
'title'
).
text
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment