Skip to content

fix(core): declare the dist-only test target in six remaining jest configs - #11486

Open
igorlukanin wants to merge 1 commit into
masterfrom
igor/core-739-dist-testmatch-remaining-six-packages
Open

fix(core): declare the dist-only test target in six remaining jest configs#11486
igorlukanin wants to merge 1 commit into
masterfrom
igor/core-739-dist-testmatch-remaining-six-packages

Conversation

@igorlukanin

Copy link
Copy Markdown
Member

Summary

  • jest.base.config.js declares no preset and no transform, so the TypeScript under a package's test/ cannot execute — those packages are meant to run their suites from compiled output in dist/test/. Six packages extended it without declaring a testMatch, so jest's default pattern collected the compiled output and the untransformable sources, and a bare jest in the package directory died with SyntaxError: Cannot use import statement outside a module. The path argument in each package's npm script (jest --verbose dist/test, jest dist/test/*.js, …) was the only thing keeping the suites runnable.
  • Each of the six now declares the dist-pointing testMatch, following the same shape and comment already used by the packages fixed earlier in this sweep: cubejs-bigquery-driver, cubejs-druid-driver, cubejs-duckdb-driver, cubejs-mysql-driver, cubejs-databricks-jdbc-driver, cubejs-backend-maven.
  • The pattern is not hoisted into jest.base.config.js, deliberately: several packages keep integration suites next to their unit ones and split the two with the path argument in their scripts, so a hoisted pattern would enroll suites needing live warehouse credentials in packages that pass no such argument.

Config-only; no source or test files change.

Why this is behaviour-preserving

Every existing script already passes a dist/test path argument, so its selection is unchanged. The only invocation whose behaviour changes is a bare jest typed by hand in a package directory — which fails today and works after.

Nothing in CI invokes these six packages' own test scripts: the per-package suites run through yarn lerna run … unit, and none of the six declares a script named unit (four have only integration:*; the others are unit-tests and unit:disabled-for-ci). The driver matrix exercises testing-drivers, not these scripts.

Test plan

  • jest --listTests diffed per (package, script) pair, before vs. after: 8 lines removed, 0 added — the removals are exactly the untransformable test/*.ts entries that a bare jest used to collect in each of the six.
  • The "existing scripts" half of that output is byte-identical on both sides (same md5), covering all 8 jest-invoking scripts across the six packages.
  • Before/after on a bare jest in cubejs-druid-driver: 2 failed, 2 skipped, 2 of 4 total (SyntaxError: Cannot use import statement outside a module, Missing semicolon) → 2 skipped, 0 of 2 total, no failures.
  • cubejs-druid-driver's in-process unit suite (dist/test/druid-query.test.js) runs green through the new config: 2 passed.
  • Each of the six configs loads under Node and yields a well-formed testMatch; eslint clean.
  • Checked that the glob loses nothing: MySqlDriverPool.disabled.ts and mysql.db.runner.ts don't match *.{test,spec}.* but were never collected before either (the first is dormant, the second a helper imported by the suite). .d.ts and .js.map files can't match the pattern. No package among the six has subdirectories under dist/test, and none sets roots, testRegex, or testPathIgnorePatterns that would interact with the added key.
  • CI must pass

Two of the six suites can't execute on a dev machine for reasons predating this change: cubejs-databricks-jdbc-driver needs the optional java native module, and cubejs-backend-maven's suite downloads a Maven distribution from a URL that now 404s (hence its script name, unit:disabled-for-ci). Both fail identically with and without this change.

@igorlukanin
igorlukanin requested review from a team as code owners August 5, 2026 18:16
@github-actions github-actions Bot added driver:mysql Issues relating to the MySQL/MariaDB driver driver:bigquery Issues related to the BigQuery driver driver:druid Issues relating to the Druid driver javascript Pull requests that update Javascript code data source driver driver:databricks driver:duckdb cubejs-jdbc-driver labels Aug 5, 2026
@claude

claude Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 2m 1s —— View job


Review: approve — config-only, claims verified. 0 blocking, 0 medium, 3 low (nits).

Full review — checklist, verification of the PR's claims, and the three nits
  • Read the PR diff
  • Verify base config and the claims about testMatch
  • Check the six packages' scripts and test layouts
  • Compare against the earlier packages in this sweep
  • Post review

What I verified independently

Claim in the PR body Verified? Evidence
jest.base.config.js has no preset/transform, so test/*.ts cannot execute jest.base.config.js:1-25 — no preset, no transform. Also no root or per-package babel.config.*/.babelrc for any of the six (only cubejs-client-dx and cubejs-client-vue3 have one), so babel-jest has nothing to apply and TS sources genuinely fail with Cannot use import statement outside a module.
Every existing script already passes a dist/test path argument, so selection is unchanged jest --verbose dist/test (bigquery, duckdb, mysql), jest dist/test/*.js (druid ×2, backend-maven), jest dist/test --forceExit (databricks).
Nothing in CI invokes these six packages' own test scripts .github/workflows/push.yml:137 is the only per-package suite runner: lerna run … unit. None of the six declares unit — they declare integration, integration:*, unit-tests, unit:disabled-for-ci. Grepping the whole .github/workflows/ tree for those script names returns nothing.
.d.ts / .js.map can't match the glob Foo.test.d.ts can't satisfy *.{test,spec}.{ts,js} — the {ts,js} group would have to match d.ts.
mysql's two non-matching files lose nothing MySqlDriverPool.disabled.ts and mysql.db.runner.ts (helper) don't match *.{test,spec}.*; neither was collected before.

Assessment

The change is correct and minimal, and the reasoning for not hoisting into jest.base.config.js is the right call — several packages keep integration suites beside unit ones and rely on the path argument to split them, so a hoisted default would silently enroll credentialed suites elsewhere in the monorepo.

The test plan is unusually rigorous for a config change (--listTests diffed per package/script pair, md5-identical on the existing-script half). I have nothing to add to it.

Nits (all non-blocking)

  1. Dead ts branch in a dist/ globdist/ holds .js only. Matches the convention in cubejs-server/cubejs-testing/cubejs-testing-drivers, so keeping it is defensible; flagged inline.
  2. Two shapes now coexist — the six new configs use dist/test/**/*, the four pre-existing ones use dist/test/* (and cubejs-cubestore-driver uses the (test|spec).(ts|js) regex-ish form). No behavioural difference today. Normalising the older ones in a follow-up would make the convention greppable. Fix this →
  3. Copy-paste drift risk — the same 5-line block is now duplicated in 6 (soon 10+) configs. An alternative that preserves the deliberate opt-in: export a named constant from jest.base.config.js (e.g. module.exports.distTestMatch = [...]) and have each package spread it in. Keeps the "not a default" property while making the pattern editable in one place. Fine as-is for this PR.

One editorial note on the description, not the code: the sentence "following the same shape and comment already used by the packages fixed earlier in this sweep" then lists the same six packages this PR changes. Presumably it should name the earlier PR's packages (cubejs-server, cubejs-testing, cubejs-testing-drivers, cubejs-cubestore-driver).

Nothing here blocks merge; the remaining checkbox (CI) is the only gate.

• [Branch](https://github.com/cube-js/cube/tree/igor/core-739-dist-testmatch-remaining-six-packages)

Comment on lines +7 to +11
// Suites run from the compiled output — the sources under test/ have no
// transform and cannot execute.
testMatch: [
'<rootDir>/dist/test/**/*.{test,spec}.{ts,js}'
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (non-blocking): ts in the extension alternation is dead weight for a dist/ glob — the compiled output is .js only (and .d.ts can't match *.{test,spec}.{ts,js}, as the PR description notes). It does match the convention already used by cubejs-server/cubejs-testing/cubejs-testing-drivers, so keeping it for consistency is defensible; just flagging that the ts branch can never fire here.

Also worth noting the new configs use dist/test/**/* while the pre-existing dist-pointing configs use single-level dist/test/*. The **/ form is strictly more permissive and there are no subdirectories today, so no behaviour difference — but the sweep now leaves two shapes in the tree. Picking one (probably **/) and normalising the older four in a follow-up would make the convention greppable.

@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.10%. Comparing base (f7ff67a) to head (18aefa0).

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

HEAD has 1 upload less than BASE
Flag BASE (f7ff67a) HEAD (18aefa0)
cubesql 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #11486       +/-   ##
===========================================
- Coverage   79.46%   59.10%   -20.36%     
===========================================
  Files         480      223      -257     
  Lines       98810    17891    -80919     
  Branches     3636     3636               
===========================================
- Hits        78515    10575    -67940     
+ Misses      19774     6795    -12979     
  Partials      521      521               
Flag Coverage Δ
cube-backend 59.10% <ø> (ø)
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

cubejs-jdbc-driver data source driver driver:bigquery Issues related to the BigQuery driver driver:databricks driver:druid Issues relating to the Druid driver driver:duckdb driver:mysql Issues relating to the MySQL/MariaDB driver javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant