Skip to content

Commit ceb7663

Browse files
authored
chore(tests): Create base jest config and extend it in each package (#9524)
* chore(tests): Create base jest config and extend it in each package * track jest.base.config.js changes in push CI WF
1 parent e68530a commit ceb7663

File tree

61 files changed

+316
-573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+316
-573
lines changed

.github/workflows/push.yml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
- 'package.json'
2020
- 'lerna.json'
2121
- 'rollup.config.js'
22+
- 'jest.base.config.js'
2223
- 'yarn.lock'
2324
branches:
2425
- 'master'
@@ -40,6 +41,7 @@ on:
4041
- 'package.json'
4142
- 'lerna.json'
4243
- 'rollup.config.js'
44+
- 'jest.base.config.js'
4345
- 'yarn.lock'
4446

4547
env:

jest.base.config.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/** @type {import('jest').Config} */
2+
module.exports = {
3+
testEnvironment: 'node',
4+
collectCoverage: true,
5+
coverageDirectory: 'coverage/',
6+
coverageReporters: ['text', 'html', 'lcov'],
7+
coveragePathIgnorePatterns: ['.*\\.d\\.ts'],
8+
collectCoverageFrom: [
9+
'dist/src/**/*.js',
10+
'dist/src/**/*.ts',
11+
],
12+
moduleDirectories: ['node_modules', '<rootDir>/node_modules'],
13+
moduleNameMapper: {
14+
// Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports.
15+
// @See https://github.com/uuidjs/uuid/issues/451
16+
'^uuid$': require.resolve('uuid'),
17+
'^yaml$': require.resolve('yaml'),
18+
},
19+
snapshotFormat: {
20+
escapeString: true, // To keep existing variant of snapshots
21+
printBasicPrototype: true
22+
}
23+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
snapshotResolver: '<rootDir>/test/snapshotResolver.js',
8+
};

packages/cubejs-api-gateway/package.json

-25
Original file line numberDiff line numberDiff line change
@@ -70,30 +70,5 @@
7070
"license": "Apache-2.0",
7171
"eslintConfig": {
7272
"extends": "../cubejs-linter"
73-
},
74-
"jest": {
75-
"testEnvironment": "node",
76-
"collectCoverage": true,
77-
"coverageReporters": [
78-
"text",
79-
"html",
80-
"lcov"
81-
],
82-
"coverageDirectory": "coverage/",
83-
"collectCoverageFrom": [
84-
"dist/src/**/*.js",
85-
"dist/src/**/*.ts"
86-
],
87-
"coveragePathIgnorePatterns": [
88-
".*\\.d\\.ts"
89-
],
90-
"moduleNameMapper": {
91-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
92-
},
93-
"snapshotResolver": "<rootDir>/test/snapshotResolver.js",
94-
"snapshotFormat": {
95-
"escapeString": true,
96-
"printBasicPrototype": true
97-
}
9873
}
9974
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
};

packages/cubejs-backend-cloud/package.json

-20
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,5 @@
4646
},
4747
"eslintConfig": {
4848
"extends": "../cubejs-linter"
49-
},
50-
"jest": {
51-
"testEnvironment": "node",
52-
"collectCoverage": true,
53-
"coverageReporters": [
54-
"text",
55-
"html",
56-
"lcov"
57-
],
58-
"coverageDirectory": "coverage/",
59-
"collectCoverageFrom": [
60-
"dist/src/**/*.js",
61-
"dist/src/**/*.ts"
62-
],
63-
"coveragePathIgnorePatterns": [
64-
".*\\.d\\.ts"
65-
],
66-
"moduleNameMapper": {
67-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
68-
}
6949
}
7050
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
};

packages/cubejs-backend-maven/package.json

-6
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,5 @@
4747
},
4848
"eslintConfig": {
4949
"extends": "../cubejs-linter"
50-
},
51-
"jest": {
52-
"testEnvironment": "node",
53-
"moduleNameMapper": {
54-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
55-
}
5650
}
5751
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
setupFilesAfterEnv: [
8+
'<rootDir>/dist/test/setup/index.js'
9+
],
10+
roots: [
11+
'<rootDir>/dist/test/'
12+
],
13+
snapshotResolver: '<rootDir>/test/snapshotResolver.js',
14+
};

packages/cubejs-backend-native/package.json

-27
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,6 @@
7777
}
7878
]
7979
},
80-
"jest": {
81-
"testEnvironment": "node",
82-
"collectCoverage": true,
83-
"coverageReporters": [
84-
"text",
85-
"html",
86-
"lcov"
87-
],
88-
"coverageDirectory": "coverage/",
89-
"roots": [
90-
"<rootDir>/dist/test/"
91-
],
92-
"setupFilesAfterEnv": [
93-
"<rootDir>/dist/test/setup/index.js"
94-
],
95-
"coveragePathIgnorePatterns": [
96-
".*\\.d\\.ts"
97-
],
98-
"moduleNameMapper": {
99-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
100-
},
101-
"snapshotResolver": "<rootDir>/test/snapshotResolver.js",
102-
"snapshotFormat": {
103-
"escapeString": true,
104-
"printBasicPrototype": true
105-
}
106-
},
10780
"eslintConfig": {
10881
"extends": "../cubejs-linter"
10982
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
};

packages/cubejs-backend-shared/package.json

-20
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,5 @@
5959
},
6060
"resolutions": {
6161
"colors": "1.4.0"
62-
},
63-
"jest": {
64-
"testEnvironment": "node",
65-
"collectCoverage": true,
66-
"coverageReporters": [
67-
"text",
68-
"html",
69-
"lcov"
70-
],
71-
"coverageDirectory": "coverage/",
72-
"collectCoverageFrom": [
73-
"dist/src/**/*.js",
74-
"dist/src/**/*.ts"
75-
],
76-
"coveragePathIgnorePatterns": [
77-
".*\\.d\\.ts"
78-
],
79-
"moduleNameMapper": {
80-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
81-
}
8262
}
8363
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
};

packages/cubejs-base-driver/package.json

-20
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,6 @@
4747
"eslintConfig": {
4848
"extends": "../cubejs-linter"
4949
},
50-
"jest": {
51-
"testEnvironment": "node",
52-
"collectCoverage": true,
53-
"coverageReporters": [
54-
"text",
55-
"html",
56-
"lcov"
57-
],
58-
"coverageDirectory": "coverage/",
59-
"collectCoverageFrom": [
60-
"dist/src/**/*.js",
61-
"dist/src/**/*.ts"
62-
],
63-
"coveragePathIgnorePatterns": [
64-
".*\\.d\\.ts"
65-
],
66-
"moduleNameMapper": {
67-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
68-
}
69-
},
7050
"publishConfig": {
7151
"access": "public"
7252
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
};

packages/cubejs-bigquery-driver/package.json

-21
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,6 @@
4848
"publishConfig": {
4949
"access": "public"
5050
},
51-
"jest": {
52-
"testEnvironment": "node",
53-
"collectCoverage": true,
54-
"coverageReporters": [
55-
"text",
56-
"html",
57-
"lcov"
58-
],
59-
"coverageDirectory": "coverage/",
60-
"collectCoverageFrom": [
61-
"dist/src/**/*.js",
62-
"dist/src/**/*.ts"
63-
],
64-
"coveragePathIgnorePatterns": [
65-
".*\\.d\\.ts"
66-
],
67-
"moduleNameMapper": {
68-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js",
69-
"^yaml$": "<rootDir>/../../node_modules/yaml/dist/index.js"
70-
}
71-
},
7251
"eslintConfig": {
7352
"extends": "../cubejs-linter"
7453
}

packages/cubejs-cli/jest.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
};

packages/cubejs-cli/package.json

-20
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,6 @@
6565
"jest": "^29",
6666
"typescript": "~5.2.2"
6767
},
68-
"jest": {
69-
"testEnvironment": "node",
70-
"collectCoverage": true,
71-
"coverageReporters": [
72-
"text",
73-
"html",
74-
"lcov"
75-
],
76-
"coverageDirectory": "coverage/",
77-
"collectCoverageFrom": [
78-
"dist/src/**/*.js",
79-
"dist/src/**/*.ts"
80-
],
81-
"coveragePathIgnorePatterns": [
82-
".*\\.d\\.ts"
83-
],
84-
"moduleNameMapper": {
85-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
86-
}
87-
},
8868
"license": "Apache-2.0",
8969
"eslintConfig": {
9070
"extends": "../cubejs-linter"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
};

packages/cubejs-clickhouse-driver/package.json

-21
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,6 @@
4545
"publishConfig": {
4646
"access": "public"
4747
},
48-
"jest": {
49-
"testEnvironment": "node",
50-
"collectCoverage": true,
51-
"coverageReporters": [
52-
"text",
53-
"html",
54-
"lcov"
55-
],
56-
"coverageDirectory": "coverage/",
57-
"collectCoverageFrom": [
58-
"dist/src/**/*.js",
59-
"dist/src/**/*.ts"
60-
],
61-
"coveragePathIgnorePatterns": [
62-
".*\\.d\\.ts"
63-
],
64-
"moduleNameMapper": {
65-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js",
66-
"^yaml$": "<rootDir>/../../node_modules/yaml/dist/index.js"
67-
}
68-
},
6948
"eslintConfig": {
7049
"extends": "../cubejs-linter"
7150
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const base = require('../../jest.base.config');
2+
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
...base,
6+
rootDir: '.',
7+
transform: {
8+
'^.+\\.js$': 'babel-jest',
9+
},
10+
};

packages/cubejs-client-core/package.json

-16
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,5 @@
4444
"eslint-plugin-import": "^2.16.0",
4545
"eslint-plugin-node": "^10.0.0",
4646
"jest": "^29"
47-
},
48-
"jest": {
49-
"testEnvironment": "node",
50-
"collectCoverage": true,
51-
"coverageReporters": [
52-
"text",
53-
"html",
54-
"lcov"
55-
],
56-
"coverageDirectory": "coverage/",
57-
"transform": {
58-
"^.+\\.js$": "babel-jest"
59-
},
60-
"moduleNameMapper": {
61-
"^uuid$": "<rootDir>/../../node_modules/uuid/dist/index.js"
62-
}
6347
}
6448
}

0 commit comments

Comments
 (0)