next.js
e7464c6a - Turbopack: migrate CSS snapshot tests to execution tests (#101232)

Commit
20 days ago
Turbopack: migrate CSS snapshot tests to execution tests (#101232) **Stack** (migrating Turbopack snapshot tests to execution tests), part 7 of 7: 1. #101211: imports, `import.meta`, TypeScript config, Node 2. #101227: comptime 3. #101228: CommonJS tree shaking 4. #101229: ESM export optimizations 5. #101230: tree shaking and scope hoisting 6. #101231: basic/chunking 7. #101232: CSS ← this PR ### What? Migrates the `css/*` and `cssmodules/*` Turbopack snapshot tests to execution tests. This is the last PR of the stack. Test-only change. ### Why? The CSS snapshots store whole emitted chunks, but each test checks one property, such as import order or `url()` rewriting. These execution tests assert that property directly. ### How? - **CSS modules:** `composes` (also from another CSS module or a package), static and dynamic imports, and deduplication are asserted at runtime through the exported class names. - **Emitted CSS:** the other tests read the emitted CSS chunks from `output/` (which the harness cleans before every run) and check one property each, not the whole file. A new shared helper, `__helpers__/css.js`, reads the chunks and parses their source comments, so the tests don't each copy that code: - absolute-URL `@import`s are hoisted without duplicates, and relative ones inlined in order - protocol-relative imports stay external - bare `@import`s resolve relative to the importing file - `layer()`, media and supports attributes of nested imports are chained - `url()` is rewritten to the emitted asset; unresolvable `url()`s and `url()` in `@supports` are kept unchanged - legacy nesting is flattened - output is minified - `@import` cycles and modules shared between chunks keep their order (most fixtures already encode the expected position in `content: 'N'`) - **Errors:** after an invalid rule, the valid rules around it are kept. Issues stay as `issues/` snapshots, and `css-parse-error`'s `.prettierignore` entry moves with the fixture. **Kept as snapshot tests across the stack** (24), because the output itself is under test or the Node.js-only execution harness can't express them: - browser runtime/chunk format: `runtime/*`, `workers/*`, `basic/chunk_loading_global`, `basic/single-chunk-entry`, `example`, `evaluated_entrry` - source maps and debug IDs: `source_maps/*`, `debug-ids/*` - transforms the execution harness doesn't configure: `swc_transforms/*`, `emotion`, `styled_components` - harness-specific setup: `comptime/define`, `env/env`, `dynamic-request/very-dynamic`, and the Web Worker cases of `imports/ignore-comments` Known gap, not addressed here: the snapshot harness doesn't discover `swc_transforms/mono_transforms`. It uses a custom entry and has no `input/index.*`. This predates the stack. Verified on this layer, the top of the stack: 442 execution and 24 snapshot tests pass. Prettier is clean. <!-- NEXT_JS_LLM --> <!-- fleet a144b357-ef78-451c-8231-ec24b8a59cec --> --------- Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Author
Parents
Loading