diff --git a/jest.base.config.js b/jest.base.config.js index 58c9b1ac1fbf0..9e952a6f193a4 100644 --- a/jest.base.config.js +++ b/jest.base.config.js @@ -1,4 +1,21 @@ -/** @type {import('jest').Config} */ +/** + * Base config for packages that test their COMPILED output. It declares no + * `preset` and no `transform`, so the TypeScript under `test/` cannot execute + * here — run `yarn tsc` first, and expect suites to run from `dist/test`. + * + * `testMatch` is deliberately left to each package rather than set here: + * several of them keep integration suites next to their unit ones and split the + * two with the path argument in their `unit` / `integration` scripts. A pattern + * hoisted into this file would apply to packages that have no such argument, + * enrolling suites that need live warehouse credentials. + * + * So a package extending this should declare its own `testMatch` pointing into + * `dist/`. Without one, jest's default picks up the untransformable sources + * under `test/` and a bare `jest` fails on `import` — the path argument in the + * npm script is then the only thing keeping the suite runnable. + * + * @type {import('jest').Config} + */ module.exports = { testEnvironment: 'node', collectCoverage: true, diff --git a/packages/cubejs-athena-driver/jest.config.js b/packages/cubejs-athena-driver/jest.config.js new file mode 100644 index 0000000000000..320b1ce4c7ff0 --- /dev/null +++ b/packages/cubejs-athena-driver/jest.config.js @@ -0,0 +1,12 @@ +const base = require('../../jest.base.config'); + +/** @type {import('jest').Config} */ +module.exports = { + ...base, + rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], +}; diff --git a/packages/cubejs-athena-driver/package.json b/packages/cubejs-athena-driver/package.json index abbddb67f1a29..4e8561a04fc4b 100644 --- a/packages/cubejs-athena-driver/package.json +++ b/packages/cubejs-athena-driver/package.json @@ -46,8 +46,5 @@ "eslintConfig": { "extends": "../cubejs-linter" }, - "jest": { - "testEnvironment": "node" - }, "license": "Apache-2.0" } diff --git a/packages/cubejs-backend-cloud/jest.config.js b/packages/cubejs-backend-cloud/jest.config.js index 4611f9c2f14da..1d24a7d898198 100644 --- a/packages/cubejs-backend-cloud/jest.config.js +++ b/packages/cubejs-backend-cloud/jest.config.js @@ -4,4 +4,9 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output — the sources under test/ have no + // transform and cannot execute. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], }; diff --git a/packages/cubejs-cli/jest.config.js b/packages/cubejs-cli/jest.config.js index 4611f9c2f14da..1d24a7d898198 100644 --- a/packages/cubejs-cli/jest.config.js +++ b/packages/cubejs-cli/jest.config.js @@ -4,4 +4,9 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output — the sources under test/ have no + // transform and cannot execute. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], }; diff --git a/packages/cubejs-clickhouse-driver/jest.config.js b/packages/cubejs-clickhouse-driver/jest.config.js index 4611f9c2f14da..320b1ce4c7ff0 100644 --- a/packages/cubejs-clickhouse-driver/jest.config.js +++ b/packages/cubejs-clickhouse-driver/jest.config.js @@ -4,4 +4,9 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], }; diff --git a/packages/cubejs-crate-driver/jest.config.js b/packages/cubejs-crate-driver/jest.config.js new file mode 100644 index 0000000000000..320b1ce4c7ff0 --- /dev/null +++ b/packages/cubejs-crate-driver/jest.config.js @@ -0,0 +1,12 @@ +const base = require('../../jest.base.config'); + +/** @type {import('jest').Config} */ +module.exports = { + ...base, + rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], +}; diff --git a/packages/cubejs-crate-driver/package.json b/packages/cubejs-crate-driver/package.json index fb144a8a28e81..1893a4b621f21 100644 --- a/packages/cubejs-crate-driver/package.json +++ b/packages/cubejs-crate-driver/package.json @@ -42,9 +42,6 @@ "publishConfig": { "access": "public" }, - "jest": { - "testEnvironment": "node" - }, "eslintConfig": { "extends": "../cubejs-linter" } diff --git a/packages/cubejs-dremio-driver/jest.config.js b/packages/cubejs-dremio-driver/jest.config.js index 7eab3a1464de5..af64947193009 100644 --- a/packages/cubejs-dremio-driver/jest.config.js +++ b/packages/cubejs-dremio-driver/jest.config.js @@ -4,7 +4,13 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], setupFiles: [ + ...base.setupFiles, './test/test-env.js' ], transformIgnorePatterns: [ diff --git a/packages/cubejs-jdbc-driver/jest.config.js b/packages/cubejs-jdbc-driver/jest.config.js new file mode 100644 index 0000000000000..1d24a7d898198 --- /dev/null +++ b/packages/cubejs-jdbc-driver/jest.config.js @@ -0,0 +1,12 @@ +const base = require('../../jest.base.config'); + +/** @type {import('jest').Config} */ +module.exports = { + ...base, + rootDir: '.', + // Suites run from the compiled output — the sources under test/ have no + // transform and cannot execute. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], +}; diff --git a/packages/cubejs-jdbc-driver/package.json b/packages/cubejs-jdbc-driver/package.json index 419da4f86e61b..afed007aed9df 100644 --- a/packages/cubejs-jdbc-driver/package.json +++ b/packages/cubejs-jdbc-driver/package.json @@ -38,9 +38,6 @@ "eslintConfig": { "extends": "../cubejs-linter" }, - "jest": { - "testEnvironment": "node" - }, "devDependencies": { "@cubejs-backend/linter": "1.7.16", "@types/node": "^22", diff --git a/packages/cubejs-ksql-driver/jest.config.js b/packages/cubejs-ksql-driver/jest.config.js index a5c4062a93d9a..dd7b3a6f15254 100644 --- a/packages/cubejs-ksql-driver/jest.config.js +++ b/packages/cubejs-ksql-driver/jest.config.js @@ -4,6 +4,11 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output — the sources under test/ have no + // transform and cannot execute. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], moduleNameMapper: { ...base.moduleNameMapper, '^axios$': require.resolve('axios'), diff --git a/packages/cubejs-pinot-driver/jest.config.js b/packages/cubejs-pinot-driver/jest.config.js index 4611f9c2f14da..320b1ce4c7ff0 100644 --- a/packages/cubejs-pinot-driver/jest.config.js +++ b/packages/cubejs-pinot-driver/jest.config.js @@ -4,4 +4,9 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], }; diff --git a/packages/cubejs-prestodb-driver/jest.config.js b/packages/cubejs-prestodb-driver/jest.config.js index 4611f9c2f14da..320b1ce4c7ff0 100644 --- a/packages/cubejs-prestodb-driver/jest.config.js +++ b/packages/cubejs-prestodb-driver/jest.config.js @@ -4,4 +4,9 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], }; diff --git a/packages/cubejs-schema-compiler/jest.config.js b/packages/cubejs-schema-compiler/jest.config.js index 07dea2fa8e884..2c0b8babeccec 100644 --- a/packages/cubejs-schema-compiler/jest.config.js +++ b/packages/cubejs-schema-compiler/jest.config.js @@ -4,6 +4,11 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], collectCoverageFrom: [ ...base.collectCoverageFrom, '!dist/src/parser/GenericSql*.js', diff --git a/packages/cubejs-server-core/jest.config.js b/packages/cubejs-server-core/jest.config.js index 225918847efb3..72486a207ae22 100644 --- a/packages/cubejs-server-core/jest.config.js +++ b/packages/cubejs-server-core/jest.config.js @@ -4,6 +4,11 @@ const base = require('../../jest.base.config'); module.exports = { ...base, rootDir: '.', + // Suites run from the compiled output — the sources under test/ have no + // transform and cannot execute. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], setupFilesAfterEnv: [ '/dist/test/setup.js' ], diff --git a/packages/cubejs-trino-driver/jest.config.js b/packages/cubejs-trino-driver/jest.config.js new file mode 100644 index 0000000000000..320b1ce4c7ff0 --- /dev/null +++ b/packages/cubejs-trino-driver/jest.config.js @@ -0,0 +1,12 @@ +const base = require('../../jest.base.config'); + +/** @type {import('jest').Config} */ +module.exports = { + ...base, + rootDir: '.', + // Suites run from the compiled output. This names every one the package has; + // the `unit` / `integration` scripts each pass a path to select their own. + testMatch: [ + '/dist/test/**/*.{test,spec}.{ts,js}' + ], +};