Skip to content

Commit cf03518

Browse files
committed
test: exclude node_modules from tsnapi package discovery
The API-snapshot suite auto-discovers workspace packages, but depending on the installed layout (pnpm `shamefullyHoist`) that discovery can walk into `node_modules` and try to snapshot dependencies like `@babel/runtime`, crashing on their directory-valued `exports` (`EISDIR`). Skip any discovered package under `node_modules` so only first-party workspace packages are snapshotted — fixing the intermittent CI failure. Built with the help of an agent.
1 parent 7605bf6 commit cf03518

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/exports.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import { describePackagesApiSnapshots } from 'tsnapi/vitest'
55
describePackagesApiSnapshots({
66
cwd: fileURLToPath(new URL('..', import.meta.url)),
77
filter(ctx) {
8+
// Only snapshot first-party workspace packages. Auto-discovery can walk
9+
// into `node_modules` depending on the installed layout (e.g. pnpm's
10+
// `shamefullyHoist`), which would try to snapshot dependencies like
11+
// `@babel/runtime` and crash on their directory-valued `exports`.
12+
if (/[\\/]node_modules[\\/]/.test(ctx.packageRoot))
13+
return false
814
const pkg = JSON.parse(
915
readFileSync(`${ctx.packageRoot}/package.json`, 'utf8'),
1016
)

0 commit comments

Comments
 (0)