Skip to content

Commit 6d9a6c8

Browse files
committed
ci: use different jest settings for production and development envs
This allows to test in CI the same compiled version of library as used by other apps in production, while testing TypeScript sources only in development mode.
1 parent 7339dd4 commit 6d9a6c8

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed
File renamed without changes.

jest.config.production.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
roots: ['<rootDir>/build/cjs'],
3+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.js$',
4+
moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
5+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
],
1717
"scripts": {
1818
"test:unit": "exit 0",
19-
"test:integration": "jest",
20-
"test:all": "run-p test:unit test:integration",
19+
"test:integration:development": "TEST_ENVIRONMENT=dev jest --config jest.config.development.js",
20+
"test:integration:production": "jest --config jest.config.production.js",
21+
"test:all": "run-p test:unit test:integration:production",
2122
"test": "npm run test:unit",
2223
"build": "tsc -p tsconfig-esm.json && tsc -p tsconfig-cjs.json && ./fixup.sh",
2324
"clean": "rm -rf build",

src/version.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const pkgInfo = require('../package.json');
1+
const pkgPath = process.env.TEST_ENVIRONMENT === 'dev' ? '../package.json' : '../../package.json';
2+
const pkgInfo = require(pkgPath);
23

34
function getVersion() {
45
return pkgInfo.version;

0 commit comments

Comments
 (0)