Files
orca/config/scripts/node-server-change-scope-enclosing-checkout.test.mjs
T
Neil fbc48858f6 fix(test): keep unit-test tooling inside the repo root in nested checkouts (#36657)
* fix(test): keep unit-test tooling inside the repo root in nested checkouts

Vitest's oxc tsconfig auto-discovery walks past the repo for files no
in-repo tsconfig owns, so a worktree nested in another checkout loaded
the enclosing checkout's tsconfig. Pin the transform tsconfig to an
explicit solution file listing the same projects auto-discovery finds.

The local module cache policy hash failed on esbuild warnings from an
ancestor package.json; only warnings located inside the root now fail.

* fix(test): guard the pinned transform tsconfig against project drift

Drop docs/site (no unit test transforms it) so its tsconfig cannot break
every transform, and fail when a project tsconfig is added or removed
without updating the pinned solution.
2026-10-31 02:50:47 -07:00

22 lines
966 B
JavaScript

import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, expect, it } from 'vitest'
import { collectNodeServerInputs } from './node-server-change-scope.mjs'
let outer
afterEach(() => rmSync(outer, { recursive: true, force: true }))
it('ignores warnings from an enclosing checkout but not from the repo', async () => {
const duplicateKey = '{ "name": "x", "name": "y" }'
outer = mkdtempSync(join(tmpdir(), 'node-server-scope-outer-'))
const root = join(outer, 'repo')
mkdirSync(root)
writeFileSync(join(outer, 'package.json'), duplicateKey)
writeFileSync(join(root, 'entry.ts'), 'export {}')
const collect = () => collectNodeServerInputs({ root, entryPoints: ['entry.ts'] })
expect([...(await collect())]).toEqual(['entry.ts'])
writeFileSync(join(root, 'package.json'), duplicateKey)
await expect(collect()).rejects.toThrow('Duplicate key')
})