test(core): enforce the dist-only test target across packages - #11487
test(core): enforce the dist-only test target across packages#11487igorlukanin wants to merge 9 commits into
Conversation
|
Claude finished @igorlukanin's task in 3m 26s —— View job Review: sound guard, one real coverage gap — 1 medium, 3 low, 2 nitsFull review (click to expand)
What I checkedRead The three-part predicate is the right shape, and the reasoning in the PR body for why it isn't keyed on Findings
Finding 1 is the one worth acting on before merge — not because it breaks the check, but because it makes the check's clean exit mean less than it appears to. Everything else is drift-proofing; no package in the tree trips 2 or 3 today. Nits
Non-blocking observations
|
|
Claude finished @igorlukanin's task in 4m 41s —— View job Re-review: all four prior findings addressed, plus a real test suite — 1 low, 3 nitsFull review (click to expand)
What changed since the last passEvery finding from the previous review is closed, and two of the three nits with it:
Three things in the new code are better than what I'd have suggested:
On the Verified, not inferredNode execution isn't permitted in this environment, so — same caveat as last time — the behavioural claims below come from reading the predicates against real values, plus these
FindingLow — Nits
Non-blocking observations
Resolved all four of my prior threads: three fixed in code, one answered with a rationale I accept. · branch |
|
Took all four findings and the three nits, in The nits, since they turned out to be the more interesting half:
Two more that came out of reviewing the fix:
Offender count is 25, up one: |
|
Claude finished @igorlukanin's task in 2m 3s —— View job Re-review of
|
|
Claude finished @igorlukanin's task in 1m 32s —— View job Re-review of
|
Summary
jest.base.config.jsdeclares nopresetand notransform, so a package extending it cannot execute TypeScript — its suites have to come fromdist/, and its config has to say so. Nothing checked that, and packages kept drifting: jest's defaulttestMatchcollects the untransformable sources, a barejestdies onimport, and the path argument in theunitscript is the only thing keeping the suite runnable.scripts/check-dist-test-target.js, run as its own step in thelintjob. It flags a package when all three hold: the resolved jest config cannot transform TypeScript, the package has TypeScript test sources, and it does not confine collection todist/.jest.config.jsor ajestkey inpackage.json, since the defect is indifferent to which one a package uses.Why the predicate is shaped this way. Two ways to get this check wrong, both of which flag packages that are already correct — and a guard that cries wolf gets deleted rather than fixed:
testMatchalone fails forever oncubejs-backend-native, which expresses the same constraint asroots: ['<rootDir>/dist/test/']. Both spellings are accepted.jest.base.config.js" fails forever oncubejs-base-driver,cubejs-backend-sharedandcubejs-query-orchestrator. They reach the base config throughjest.base-ts.config.js, which addspreset: ts-jestand a transform — so they run from source deliberately. Asking the resolved config whether it can compile a.tsfile answers that directly.Checking that a transform merely exists isn't enough either:
transform: {}is jest's idiom for switching transformation off, and{'^.+\\.js$': 'babel-jest'}covers no.tsat all. Both are truthy, and both leave the package broken. The transform patterns are tested against a representative.tsfilename instead.Likewise, a declared
testMatchthat points attest/rather thandist/test/is still the bug, so the value has to targetdist/, not just exist.This is currently red, by design
Run against
masterit reports 24 packages. That is the defect it exists to find, not a fault in the check — but it does mean this cannot merge until those are fixed. It should go in last, after the in-flight PRs that fix them.Five of the 24 are ones no in-flight PR covers — they configure jest through
package.jsonrather than a config file, so they were never in scope. Verified directly rather than inferred:npx jestincubejs-postgres-driverreports 2 failed / 2 passed suites and incubejs-questdb-driver3 failed / 1 passed, every failureJest encountered an unexpected token. They're tracked separately; this PR deliberately doesn't widen to fix them.Test plan
master, naming each package.testMatchintodist/,rootsintodist/), includingrootsgiven as a bare string.testMatch/rootspointing at the sources is still flagged; so is an empty array, and a list mixing adist/entry with a source one. A!-negated entry doesn't have to namedist/.transform: {}, a.js-only transform, and a non-TypeScript preset all fail to exempt a package with.tstests; ats-jesttransform or preset does exempt it..tsxsuites,.spec.files, and tests outsidetest/(e.g. undersrc/) all count.package.jsonis read, and is subject to the same constraint..tstests is caught; adding either constraint clears it.dist/. Runs in ~0.1s.