Skip to content

Commit

Permalink
test: Make css bundle assertion work also for turbopack (#62127)
Browse files Browse the repository at this point in the history
### What?

Fix one assertion about CSS files emitted by turbopack.

### Why?

Turbopack generates `/_next/static/chunks/2225ce._.css`, which does not
match the regex.
Note that it has `._.css`. The previous assertions match on
`[^.]+\.css`, which does not support two dots in the file name.

I tried `/<link rel="stylesheet" href=".+\.css(\?v=\d+)?"/g`, but it
captured 3 `link` tags at once. So I used `/<link rel="stylesheet"
href="[^<]+\.css(\?v=\d+)?"/g`.


### How?

Closes PACK-2413
  • Loading branch information
kdy1 authored Feb 19, 2024
1 parent ab487cb commit d8865d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test/e2e/app-dir/app-css/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,11 @@ createNextDescribe(
describe('chunks', () => {
it('should bundle css resources into chunks', async () => {
const html = await next.render('/dashboard')

expect(
[
...html.matchAll(
/<link rel="stylesheet" href="[^.]+\.css(\?v=\d+)?"/g
/<link rel="stylesheet" href="[^<]+\.css(\?v=\d+)?"/g
),
].length
).toBe(3)
Expand Down
4 changes: 2 additions & 2 deletions test/turbopack-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2475,10 +2475,10 @@
"app dir - css sass support server layouts should support sass/scss modules inside server layouts",
"app dir - css sass support server pages should support global sass/scss inside server pages",
"app dir - css sass support server pages should support sass/scss modules inside server pages",
"app dir - css HMR should not create duplicate link tags during HMR"
"app dir - css HMR should not create duplicate link tags during HMR",
"app dir - css css support chunks should bundle css resources into chunks"
],
"failed": [
"app dir - css css support chunks should bundle css resources into chunks",
"app dir - css css support should not preload styles twice during HMR"
],
"pending": [
Expand Down

0 comments on commit d8865d0

Please sign in to comment.