Skip to content

Commit 3144adb

Browse files
committed
fix(test): stop the suite depending on generated Nuxt types
CI ran zero tests: `[TSCONFIG_ERROR] Failed to load tsconfig` for all 10 files, every suite failed, and it passed locally the whole time. oxc resolves the nearest tsconfig for each file it transforms. The root `tsconfig.json` is a project-references stub pointing into `playground/.nuxt/`, which only exists after `nuxt prepare` — and CI runs `pnpm test` before `pnpm dev:prepare`, which I ordered that way on purpose so lint and tests fail fast. Locally a generated `.nuxt` was always lying around, so the dependency was invisible. Reproduced by moving `playground/.nuxt` aside; it also means `pnpm test` never worked from a fresh clone. Turn tsconfig resolution off for the transform instead of reordering CI. Nothing under test needs tsconfig-driven semantics — no decorators, no path aliases, relative imports throughout — so the suite becomes hermetic rather than dependent on a build artefact, which is what a unit test should be. A scoped `test/tsconfig.json` alone was not enough: it fixed `test/setup.ts` and then the imported sources failed instead, each resolving the root stub from its own directory. It stays for editors, which otherwise have no project covering `test/`, but it is not what the transform reads. Verified both ways: with `playground/.nuxt` present and absent, 103 tests pass.
1 parent e0f902f commit 3144adb

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

test/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"strict": true,
7+
"noUncheckedIndexedAccess": true,
8+
"verbatimModuleSyntax": true,
9+
"skipLibCheck": true,
10+
"types": ["vitest/globals", "node"]
11+
},
12+
"include": ["./**/*.ts"]
13+
}

vitest.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import { defineConfig } from 'vitest/config'
22

33
export default defineConfig({
4+
// Transform without consulting any tsconfig.
5+
//
6+
// oxc otherwise resolves the *nearest* tsconfig per transformed file, and the root
7+
// `tsconfig.json` is a project-references stub pointing into `playground/.nuxt/`,
8+
// which only exists once `nuxt prepare` has run. So `pnpm test` from a fresh clone
9+
// — or in CI, which runs it before `dev:prepare` on purpose so it fails fast —
10+
// reported `[TSCONFIG_ERROR] Tsconfig not found` for every file and ran zero tests,
11+
// while passing locally purely because a generated `.nuxt` happened to be lying
12+
// around. Reproduced by moving `playground/.nuxt` aside.
13+
//
14+
// Nothing under test needs tsconfig-driven semantics: no decorators, no path
15+
// aliases, relative imports throughout. Opting out makes the suite hermetic
16+
// instead of dependent on build artefacts. `test/tsconfig.json` still exists, for
17+
// editors — it is not what the transform reads.
18+
//
19+
// `tsconfig` is absent from Vite's `OxcOptions` type but forwarded verbatim to
20+
// `transformSync`, hence the cast.
21+
oxc: { tsconfig: false } as never,
422
test: {
523
include: ['test/**/*.test.ts'],
624
setupFiles: ['test/setup.ts'],

0 commit comments

Comments
 (0)