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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 23 additions & 0 deletions
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+
};
Lines changed: 8 additions & 0 deletions
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

Lines changed: 0 additions & 25 deletions
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
}
Lines changed: 7 additions & 0 deletions
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

Lines changed: 0 additions & 20 deletions
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
}
Lines changed: 7 additions & 0 deletions
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

Lines changed: 0 additions & 6 deletions
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
}
Lines changed: 14 additions & 0 deletions
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

Lines changed: 0 additions & 27 deletions
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
},

0 commit comments

Comments
 (0)