Skip to content

Commit

Permalink
chore: use env variable to choose the webpack version to test
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Nov 4, 2020
1 parent 77d9256 commit c070aeb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
15 changes: 0 additions & 15 deletions jest-webpack5.config.js

This file was deleted.

20 changes: 19 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
module.exports = {
const config = {
preset: 'ts-jest',
testTimeout: 10000,
testEnvironment: 'node',
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/'],
}

if (process.env.WEBPACK5) {
module.exports = {
...config,

globals: {
'ts-jest': {
diagnostics: false,
},
},
moduleNameMapper: {
'^webpack$': 'webpack5',
'^webpack/(.*)': 'webpack5/$1',
},
}
} else {
module.exports = config
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "tsc",
"pretest": "tsc",
"test": "jest --coverage",
"test:webpack5": "jest -c jest-webpack5.config.js --coverage",
"test:webpack5": "WEBPACK5=true jest -c --coverage",
"dev-example": "webpack-dev-server --config example/webpack.config.js --inline --hot",
"build-example": "rm -rf example/dist && webpack --config example/webpack.config.js --env.prod",
"lint": "prettier --write --parser typescript \"{src,test}/**/*.{j,t}s\"",
Expand Down

0 comments on commit c070aeb

Please # to comment.