fix(core): declare the dist-only test target in each package's jest config - #11484
fix(core): declare the dist-only test target in each package's jest config#11484igorlukanin wants to merge 2 commits into
Conversation
|
Claude finished @igorlukanin's task in 4m 9s —— View job Approach is right and the diff is correct — 0 blocking, 3 non-blocking (1 medium, 2 low)Full review — verification of the PR's claims, 3 inline comments
VerdictThe diagnosis is accurate and the fix is the right shape. The reasoning in the PR body about why not to hoist What I verified independentlyThe narrower pattern doesn't silently drop anything. Replacing jest's default
So the "111 additions, no suite lost" claim checks out, not just by count but by mechanism. Every one of the thirteen The anti-hoisting argument is real, not theoretical. The two comment variants are applied consistently. The Non-blocking feedback (3 inline comments)
Nothing to report onSecurity, performance, error handling and input sanitization are all out of scope for a change that only touches jest configuration. No test coverage to add — the change is about which tests get collected, and the PR's before/after suite counts are the appropriate evidence. Docs need no update; the base config's new header comment is the right place for this explanation and is well written. What I could not checkI reviewed statically and did not run |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #11484 +/- ##
===========================================
- Coverage 79.46% 58.59% -20.88%
===========================================
Files 480 233 -247
Lines 98810 18358 -80452
Branches 3636 3745 +109
===========================================
- Hits 78515 10756 -67759
+ Misses 19774 7071 -12703
- Partials 521 531 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Claude finished @igorlukanin's task in 1m 22s —— View job New commit addresses the dremio nit correctly — no new findings; 2 prior threads still open (both non-blocking)Incremental review of `8d9004b`
What changed since the last reviewOne commit, one line: setupFiles: [
...base.setupFiles,
'./test/test-env.js'
],Verification
Thread status
Both open threads are documentation/consistency observations, not defects. Neither blocks merge. What I could not checkI reviewed statically again. The sandbox blocked |
Issue
Thirteen packages test their compiled output, but only their
unitscript said so. The script's path argument —jest dist/test/unit— was the only thing expressing it; the jest config didn't.jest.base.config.jsdeclares nopreset, notransformand notestMatch, so each of these packages inherited jest's defaulttestMatch, which collects the TypeScript undertest/that nothing can transform. A barejestin any of them picks up sources that die onimport:It collects
dist/test/unit/params-escaping.test.jsandtest/unit/params-escaping.test.ts, and the second one cannot run.The asymmetry in the base config is the tell:
collectCoverageFromis already['dist/src/**/*.js', 'dist/src/**/*.ts']. It knows it operates ondistfor coverage, then omits it for collection. The siblingjest.base-ts.config.jsdoes declare its intent (testMatch: ['<rootDir>/test/**/*.test.ts']) right next to the preset and transform that make it work.The consequence is that a test file can stop being collected and nobody notices, because the script's path filter papers over whatever the config says.
Fix
Each package declares its own
testMatchpointing intodist/:Nine packages already had a
jest.config.jsand needed only that line. Four had none —cubejs-athena-driver,cubejs-crate-driver,cubejs-jdbc-driver,cubejs-trino-driver— so they had nothing to inherit a fix into; they get a config, and the now-redundantjest: { testEnvironment: 'node' }key comes out of theirpackage.json(the base config suppliestestEnvironment)..spec.is in the pattern because jest's defaulttestMatchaccepted it, and pinning this must not quietly drop a suite.Why the pattern is the whole
dist/testtree, notdist/test/unitPinning each config to the narrower path its
unitscript names looks tighter, and it is wrong: eight of these packages also haveintegrationscripts pointing atdist/test/integration, and atestMatchofdist/test/unitmakes those collect nothing.A path argument is a filter applied within
testMatch, not a replacement for it, so the broad pattern keeps both scripts working:jest dist/test/unitjest dist/test/integrationjesttestPathIgnorePatterns: ['/dist/test/integration/']is the obvious alternative and does not work: it overrides the path argument, sojest dist/test/integrationcollects zero.cubejs-backend-nativeuses that key for its bridge tests, but only because those have a separate config file (jest-bridge.config.js) to run under.The four packages in the repo that already pin a dist target use a single-star form (
dist/test/*.{test,spec}.{ts,js}). That form is not transferable here — ten of these thirteen keep their suites in subdirectories, and applying it tocubejs-schema-compilercollects 0 of its 35 suites. Hence the double star.Verification
Per package: built with
yarn tsc, then compared what each script collects before and after, and ran the suite.unit, before → aftercubejs-athena-drivercubejs-backend-cloudcubejs-clicubejs-clickhouse-drivercubejs-crate-drivercubejs-dremio-drivercubejs-jdbc-drivercubejs-ksql-drivercubejs-pinot-drivercubejs-prestodb-drivercubejs-schema-compilercubejs-server-corecubejs-trino-driverEvery count is unchanged, so no suite was dropped or gained. Additionally checked:
integration*script variants still collect what they did (includingintegration:mssql/:mysql/:postgres/:clickhouseincubejs-schema-compiler, andintegration:athena/:crate/:dremio/:pinot/:presto/:trino). This is the regression the narrow pattern would have caused.jestnow collects zero non-distfiles in all thirteen — the reported bug.yarn lerna run … unitstill passes each script's own path argument, and every one of the thirteen carries one..d.tsoutput is not collected —foo.test.d.tshas.dbetween.test.and the extension, so it does not match the pattern.dist/testthat aren't suites (global-setup.js,setup.js,snapshotResolver.js) are not collected.Live-infrastructure suites keep their existing exclusions.
cubejs-athena-driver,cubejs-dremio-driver,cubejs-pinot-driverandcubejs-crate-drivereach hold test files outside the path theirunitscript names —AthenaDriver.test.ts,DremioQuery.test.ts,Pinot.test.ts,CrateDriver.test.tsand friends. Those look like the same defect but are not: every one drives testcontainers, Docker Compose or a real engine, and simply lives outside atest/integration/folder. Pinning to the script's path preserves that.What the four new config files also pick up
cubejs-athena-driver,cubejs-crate-driverandcubejs-jdbc-driverpreviously ran onpackage.json#jest: { testEnvironment: 'node' }, andcubejs-trino-driveron jest's bare defaults — none of the four loadedjest.base.config.jsat all. Extending it now also brings incollectCoverage,coverageDirectory/coverageReporters,moduleNameMapper,setupFilesandsnapshotFormat, so...baseis not inert in these four the way it is in the other nine.Checked the ones that could bite: none of the four has a
__snapshots__directory, sosnapshotFormatcan't invalidate committed snapshots;**/coverageis already gitignored, so the new output stays untracked; andjest.setup.jsis only aglobalThis.cryptopolyfill, itself a no-op on Node 18+. The one live effect is thatyarn unitin these four now runs coverage instrumentation and prints a table where it didn't before. That's the intended uniformity, on suites of 3-10 tests each.Not in this PR
cubejs-api-gatewayhas the identical gap; it is fixed in #11482, which touches the same line of the same file. Leaving it there avoids a conflict.The convention this documents still isn't enforced, and six other packages (
cubejs-bigquery-driver,cubejs-druid-driver,cubejs-duckdb-driver,cubejs-mysql-driver,cubejs-databricks-jdbc-driver,cubejs-backend-maven) have the same gap. Tracked separately in CORE-739.