next.js
e2f098ba - test(turbopack-tracing): sync new unit cases from vercel/nft (#102593)

Commit
1 day ago
test(turbopack-tracing): sync new unit cases from vercel/nft (#102593) ### What? Syncs the `turbopack-tracing` unit test fixtures with the latest upstream [vercel/nft](https://github.com/vercel/nft) test cases. This imports the 12 unit cases that exist upstream but were missing here. Upstream revision: [`vercel/nft@d1f98ddd948353db963eb11fce87dcca5647ee41`](https://github.com/vercel/nft/commit/d1f98ddd948353db963eb11fce87dcca5647ee41) (default branch, 2026-11-30). ### Why? Keeping the Turbopack tracing tests aligned with nft's test suite catches tracing behaviour that nft covers but Turbopack doesn't. ### How? - Copied each missing `test/unit/<case>` directory verbatim from upstream into `turbopack/crates/turbopack-tracing/tests/node-file-trace/test/unit/`. They were then formatted with the repo's prettier config, the same as the existing fixtures. - The `.env` fixture in `env-file-from-pkg` is force-added because the root `.gitignore` ignores `.env*`. It only contains `MY_SECRET=value`. - Registered the cases in `tests/unit.rs`. The two `module-create-require-*-alias` cases were added to the `input.mjs` entry list. - Upstream integration cases: all already present, so none were imported. - Nothing existing was changed: no fixture, expected output, harness adaptation, exclusion, or the vendored `unit.test.js` copy. - For two of the new cases Turbopack traces a superset of nft's output. Their `output.js` snapshots list the extra files under a `// Over-traced by Turbopack` comment, and the cases are enabled. **Added cases (12):** | Case | Status | | --- | --- | | `computed-object-key` | ✅ passes | | `esm-require-exports-conditions` | ✅ passes | | `logical-fallback-wildcard` | ✅ passes | | `module-create-require-named-import-alias` | ✅ passes | | `module-create-require-namespace-alias` | ✅ passes | | `require-trailing-slash` | ✅ passes | | `import-meta-url-replace` | ✅ passes, snapshot also lists the case's `output.js` (over-traced) | | `logical-fallback` | ✅ passes, snapshot also lists the case's `output.js` and all 8 files of the sibling `logical-fallback-wildcard` case (over-traced) | | `argon2-cjs` | ⏭️ commented out: the fixture only tests nft's hardcoded `argon2` special case, which emits the package's native binary directories | | `env-file-from-pkg` | ⏭️ commented out: the package reads `.env` via `path.resolve(process.cwd(), '.env')`. Turbopack intentionally doesn't resolve `process.cwd()` inside `node_modules` (`allow_project_root_tracing`), while nft does | | `logical-conditional` | ⏭️ commented out: `require(false \|\| (cond ? './a' : './b'))` traces neither `a.js` nor `b.js` | | `pkg-main-html` | ⏭️ commented out: the package's `main` is `index.html`. Turbopack has no module type for `.html`, so the resolved file becomes an unknown module and is dropped from the trace, along with the package's `package.json`; nft emits it as a plain asset | Skips use the file's existing mechanism: a commented-out `#[case]` with a short comment above it describing what was observed. The fixtures stay in the tree so the cases can be re-enabled later. The four remaining skips are differences in tracing behaviour. Changing the tracing implementation is out of scope for this test-only sync. ### Verification - `cargo test -p turbopack-tracing --test unit`: 106 passed, 0 failed. This covers the 98 existing cases plus the 8 enabled new ones. - Before applying any skips or snapshot changes: 104 passed, 6 failed. The same 6 cases failed with the same diffs in 3 consecutive runs. - `cargo fmt -p turbopack-tracing -- --check` - `prettier@3.6.2` (repo version) on the added fixtures - Not run: `cargo test -p turbopack-tracing --test node-file-trace` (integration). No integration cases changed, and it needs a full `pnpm install` of the integration fixture dependencies. <!-- NEXT_JS_LLM --> <!-- fleet 016063b9-5d20-411b-8654-b45edb426050 --> --------- Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Author
Parents
Loading