fix(core-typescript): tighten jsdom config tests + document cycle avoidance
- Replace arrayContaining with toEqual on setupFiles + include — captures actual mergeConfig array-concatenation behavior so future changes to setup/node.ts surface in this test. - Document in core-typescript/AGENTS.md why @repo/core-testing is not a devDep here (would create a circular dependency with core-testing). Reviewer: superpowers:code-reviewer (Task 2 of Plan 7). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,15 @@
|
|||||||
|
|
||||||
Shared TypeScript base configs (`tsconfig.json` files) and Vitest base config, consumed by all packages.
|
Shared TypeScript base configs (`tsconfig.json` files) and Vitest base config, consumed by all packages.
|
||||||
|
|
||||||
|
## Why `@repo/core-testing` is not a devDependency here
|
||||||
|
|
||||||
|
Plan 7 Step 9 originally said to add it. Doing so creates a circular dependency
|
||||||
|
because `@repo/core-testing` already depends on `@repo/core-typescript` for its
|
||||||
|
own tsconfig. The base configs reference `@repo/core-testing/setup/{node,jsdom}`
|
||||||
|
as STRING paths in `setupFiles` — these are resolved at Vitest execution time
|
||||||
|
by the consuming feature package, not by `core-typescript` itself. Each feature
|
||||||
|
package therefore lists `@repo/core-testing` in its own `devDependencies`.
|
||||||
|
|
||||||
## What it owns
|
## What it owns
|
||||||
|
|
||||||
- **`base.json`** — Base `tsconfig.json`: target ES2022, module ESM, `experimentalDecorators` + `emitDecoratorMetadata` for InversifyJS
|
- **`base.json`** — Base `tsconfig.json`: target ES2022, module ESM, `experimentalDecorators` + `emitDecoratorMetadata` for InversifyJS
|
||||||
|
|||||||
@@ -1,19 +1,30 @@
|
|||||||
import { describe, it, expect } from "vitest";
|
import { describe, it, expect } from "vitest";
|
||||||
import { jsdomVitestConfig } from "./vitest.base.jsdom";
|
import { jsdomVitestConfig } from "./vitest.base.jsdom";
|
||||||
|
|
||||||
|
// jsdomVitestConfig is built with mergeConfig(nodeVitestConfig, ...).
|
||||||
|
// mergeConfig concatenates arrays rather than replacing them, so:
|
||||||
|
// - setupFiles inherits the node setup file (currently a no-op) AND adds the jsdom one
|
||||||
|
// - include inherits the node patterns AND adds the tsx-aware patterns (the file globs deduplicate at resolution)
|
||||||
|
// We assert the EXACT merged arrays so any future change to setup/node.ts or to include
|
||||||
|
// behavior is consciously visible in this test.
|
||||||
|
|
||||||
describe("jsdomVitestConfig", () => {
|
describe("jsdomVitestConfig", () => {
|
||||||
it("uses jsdom environment", () => {
|
it("uses jsdom environment", () => {
|
||||||
expect(jsdomVitestConfig.test?.environment).toBe("jsdom");
|
expect(jsdomVitestConfig.test?.environment).toBe("jsdom");
|
||||||
});
|
});
|
||||||
it("loads the jsdom setup file", () => {
|
it("loads both the node setup (no-op) and jsdom setup files", () => {
|
||||||
expect(jsdomVitestConfig.test?.setupFiles).toEqual(
|
expect(jsdomVitestConfig.test?.setupFiles).toEqual([
|
||||||
expect.arrayContaining(["@repo/core-testing/setup/jsdom"]),
|
"@repo/core-testing/setup/node",
|
||||||
);
|
"@repo/core-testing/setup/jsdom",
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
it("includes tsx files", () => {
|
it("merges include globs from node base with the tsx-aware patterns", () => {
|
||||||
expect(jsdomVitestConfig.test?.include).toEqual(
|
expect(jsdomVitestConfig.test?.include).toEqual([
|
||||||
expect.arrayContaining(["src/**/*.test.{ts,tsx}", "tests/**/*.test.{ts,tsx}"]),
|
"src/**/*.test.ts",
|
||||||
);
|
"tests/**/*.test.ts",
|
||||||
|
"src/**/*.test.{ts,tsx}",
|
||||||
|
"tests/**/*.test.{ts,tsx}",
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
it("inherits clearMocks from node base", () => {
|
it("inherits clearMocks from node base", () => {
|
||||||
expect(jsdomVitestConfig.test?.clearMocks).toBe(true);
|
expect(jsdomVitestConfig.test?.clearMocks).toBe(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user