Skip to content

fix(core): declare the dist-only test target in five package.json-configured packages - #11489

Open
igorlukanin wants to merge 1 commit into
masterfrom
igor/core-742-dist-test-target-in-package-json-key-packages
Open

fix(core): declare the dist-only test target in five package.json-configured packages#11489
igorlukanin wants to merge 1 commit into
masterfrom
igor/core-742-dist-test-target-in-package-json-key-packages

Conversation

@igorlukanin

Copy link
Copy Markdown
Member

Summary

  • Five driver packages expressed their jest config as an inline jest key in package.json rather than a jest.config.js, so the dist-only convention never reached them: each has TypeScript test sources, no transform that can compile them, and nothing confining collection to dist/. A bare jest collected the sources and failed to parse them — the dist/test path argument in each package's script was the only thing keeping the suite runnable.
  • Each one now extends jest.base.config.js and declares a dist-pointing testMatch, matching the convention the other packages in this class already follow. The inline testEnvironment: 'node' is dropped because the base config already sets it.
  • cubejs-firebolt-driver is the one non-mechanical case: its inline key also carried setupFiles: ['./test/test-env.js'], and the base config declares its own setupFiles, so the new config unions the two rather than letting the spread drop it. That file maps the DRIVERS_TESTS_FIREBOLT_* env vars onto the CUBEJS_DB_* names the driver reads, and it stays a source path — tsc has no allowJs, so it is never emitted into dist/.

Three of these five (postgres, mongobi, firebolt) are exercised by the integration matrix, which runs lerna run integration:<db>. Since jest intersects a script's path argument with testMatch, the risk here is a config narrower than the path argument silently shrinking what CI runs, so that is what the test plan proves rather than assumes.

Test plan

  • jest --listTests captured before vs after for every jest-invoking script in all five packages: byte-identical on both sides (md5-matched per package) — no existing script collects fewer suites than it did before.
  • Bare jest in each package: 9 untransformable test/*.ts entries no longer collected, 0 compiled suites lost.
  • Red-checked the defect: with the change backed out, jest in cubejs-postgres-driver fails test/type-parsers.test.ts with SyntaxError: Cannot use import statement outside a module; with it, only dist/test/type-parsers.test.js is collected and passes (3 tests).
  • cubejs-firebolt-driver's resolved setupFiles asserted to contain both the base setup file and test/test-env.js, and a suite run through the new config to confirm both resolve at run time (3 passed).
  • All five configs load under Node with a well-formed testMatch; eslint clean.
  • CI must pass.

@igorlukanin
igorlukanin requested a review from a team as a code owner August 5, 2026 19:27
@github-actions github-actions Bot added driver:mongodb Issues relating to the MongoBI driver driver:postgres Issues relating to the Postgres driver driver:questdb javascript Pull requests that update Javascript code driver:firebolt data source driver driver:materialize labels Aug 5, 2026
@claude

claude Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 3m 16s —— View job


Review: approve in spirit — mechanically correct, no regressions found. 0 high, 0 medium, 3 low (1 inline, 2 informational).

Full review
  • Read PR diff
  • Check jest.base.config.js and the convention in sibling packages
  • Verify the jest-invoking scripts in all five packages
  • Verify the firebolt setupFiles union resolves
  • Trace the CI integration matrix to confirm nothing shrinks
  • Post review

Verification

I could not run jest here (no node_modules in this checkout), so this is a static trace rather than a re-run of your test plan. Everything I could check independently holds:

No script loses suites. All 9 test sources across the five packages live directly under test/ and are .ts:

firebolt:    FireboltDriver.test.ts  FireboltQuery.test.ts  autostart.test.ts
materialize: MaterializeDriver.test.ts
mongobi:     MongoBiDriver.test.ts
postgres:    PostgresDriver.test.ts  type-parsers.test.ts
questdb:     QuestDriver.test.ts  QuestQuery.test.ts

No __tests__ dirs, no test files outside test/, no .js tests. Each tsconfig.json has include: ["src", "test"] with rootDir: "." and outDir: "dist", so all nine land in dist/test/. Every jest-invoking script already passes dist/test as a positional (integration:postgres, integration:questdb, integration:materializejest --verbose dist/test; integration:mongobijest dist/test; integration:fireboltjest --verbose dist/test --runInBand). Since the positional is intersected with testMatch and the new testMatch is a superset of dist/test/*, the intersection is unchanged. Matches your md5-identical --listTests result.

Firebolt setupFiles is right, and it's the only place in the diff that needed thought. base.setupFiles is ['../../jest.setup.js'] — a relative path, resolved against rootDir (. = the package dir), so it still lands on the repo-root jest.setup.js (the globalThis.crypto webcrypto polyfill). Unioning rather than replacing preserves it. The <rootDir>/test/test-env.js path is correct: allowJs is off, so tsc never emits it into dist/, and the file is only read at test time. Its DRIVERS_TESTS_FIREBOLT_*CUBEJS_DB_* / CUBEJS_FIREBOLT_* mapping lines up exactly with the secrets set in the integration job in .github/workflows/push.yml.

Adjacent inconsistency (out of scope, worth a follow-up). packages/cubejs-dremio-driver/jest.config.js:7-9 does the thing this PR correctly avoids — it sets setupFiles: ['./test/test-env.js'] without spreading base.setupFiles, so the root jest.setup.js is dropped there. Benign on Node 20+ (where globalThis.crypto already exists) and dremio is currently commented out of the matrix, but it's the same latent trap. Fix this →

Low-severity notes

  1. testMatch spelling diverges from the existing dist-only configs — see the inline comment on packages/cubejs-postgres-driver/jest.config.js.

  2. These five packages now collect coverage, which they never did before. jest.base.config.js:4-11 sets collectCoverage: true with collectCoverageFrom: ['dist/src/**/*.js', 'dist/src/**/*.ts']. The inline jest keys being removed had no coverage settings, so this is a new side effect for the three packages in the matrix (postgres, mongobi, firebolt): instrumentation overhead on integration runs (30-min timeout with 3 retries — should be fine, but it's a real delta), plus new packages/*/coverage/lcov.info files that .github/actions/codecov-fix.sh will pick up in its glob. That script rewrites SF:src/ only, while collectCoverageFrom points at dist/src, so the new entries may land in the combined lcov unrewritten. Consistent with every other base-config package, so not a regression introduced here — flagging so it isn't a surprise if codecov path mapping shifts.

  3. Declaring the target doesn't make these suites run. Independent of this PR, but adjacent to its intent: none of the five packages has a unit script, and the unit CI job runs yarn lerna run unit — so the DB-free tests here (postgres/type-parsers.test.ts, questdb/QuestQuery.test.ts, firebolt/FireboltQuery.test.ts) never run in the unit job. firebolt and postgres at least get exercised via the integration matrix, but integration:materialize and integration:questdb aren't in the matrix db list at all, so MaterializeDriver.test.ts and QuestQuery.test.ts don't run in CI anywhere. A follow-up adding a unit script scoped to the non-DB suites would give type-parsers.test.ts and QuestQuery.test.ts actual CI coverage — they're cheap, pure-function/query-builder tests.

Other focus areas

Security, performance, input sanitization, error handling: not applicable — the diff is test-harness configuration only, no runtime code paths, no published files (files is ["dist/src", "index.js"] in each package, so neither the new jest.config.js nor test-env.js ships). Documentation: config-level comments are clear and explain the why, including the non-obvious allowJs/setupFiles reasoning; no user-facing docs needed.

Nice touch red-checking the defect by backing the change out and confirming the SyntaxError: Cannot use import statement outside a module on postgres/type-parsers.test.ts — that's the part that makes the rest of the test plan credible.

• branch `igor/core-742-dist-test-target-in-package-json-key-packages`

Comment thread packages/cubejs-postgres-driver/jest.config.js
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.41%. Comparing base (f7ff67a) to head (a39a963).

❗ There is a different number of reports uploaded between BASE (f7ff67a) and HEAD (a39a963). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (f7ff67a) HEAD (a39a963)
cubesql 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #11489       +/-   ##
===========================================
- Coverage   79.46%   59.41%   -20.06%     
===========================================
  Files         480      235      -245     
  Lines       98810    18384    -80426     
  Branches     3636     3714       +78     
===========================================
- Hits        78515    10922    -67593     
+ Misses      19774     6933    -12841     
- Partials      521      529        +8     
Flag Coverage Δ
cube-backend 59.41% <ø> (+0.30%) ⬆️
cubesql ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data source driver driver:firebolt driver:materialize driver:mongodb Issues relating to the MongoBI driver driver:postgres Issues relating to the Postgres driver driver:questdb javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant