Skip to content

Commit fe0eb45

Browse files
authored
Merge pull request webpack#6565 from niieani/jest
Migration of tests to Jest
2 parents 7b81a06 + 9958930 commit fe0eb45

File tree

451 files changed

+5887
-4586
lines changed

Some content is hidden

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

451 files changed

+5887
-4586
lines changed

.eslintrc.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
plugins: ["prettier", "node"],
3+
plugins: ["prettier", "node", "jest"],
44
extends: ["eslint:recommended", "plugin:node/recommended", "plugin:prettier/recommended"],
55
env: {
66
node: true,
@@ -13,7 +13,6 @@ module.exports = {
1313
"prettier/prettier": "error",
1414
"no-undef": "error",
1515
"no-extra-semi": "error",
16-
"semi": "error",
1716
"no-template-curly-in-string": "error",
1817
"no-caller": "error",
1918
"no-control-regex": "off",
@@ -56,7 +55,7 @@ module.exports = {
5655
{
5756
files: ["test/**/*.js"],
5857
env: {
59-
mocha: true,
58+
"jest/globals": true
6059
}
6160
}
6261
]

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ matrix:
1717
env: NO_WATCH_TESTS=1 JOB_PART=lint
1818
- os: linux
1919
node_js: "8"
20-
env: NO_WATCH_TESTS=1 JOB_PART=integration
20+
env: NO_WATCH_TESTS=1 JEST=--maxWorkers=2 JOB_PART=integration
2121
- os: linux
2222
node_js: "8"
2323
env: NO_WATCH_TESTS=1 JOB_PART=unit
2424
- os: linux
2525
node_js: "6"
26-
env: NO_WATCH_TESTS=1 JOB_PART=integration
26+
env: NO_WATCH_TESTS=1 JEST=--runInBand JOB_PART=integration
2727
- os: osx
2828
node_js: "8"
29-
env: NO_WATCH_TESTS=1 JOB_PART=integration
29+
env: NO_WATCH_TESTS=1 JEST=--maxWorkers=2 JOB_PART=integration
3030
allow_failures:
3131
- os: osx
3232
fast_finish: true

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ environment:
1616
job_part: unit
1717
- nodejs_version: 8
1818
job_part: integration
19+
jest: --maxWorkers=2
1920
- nodejs_version: 6
2021
job_part: integration
22+
jest: --runInBand
2123

2224
install:
2325
- ps: Install-Product node $env:nodejs_version x64
@@ -35,5 +37,6 @@ test_script:
3537
- node --version
3638
- npm --version
3739
- yarn --version
40+
- cmd: set JEST=%jest%
3841
- cmd: npm run appveyor:%job_part%
3942
- cmd: npm install -g codecov && codecov -F %job_part%

package.json

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"es6-promise-polyfill": "^1.1.1",
3939
"eslint": "^4.19.1",
4040
"eslint-config-prettier": "^2.9.0",
41+
"eslint-plugin-jest": "21.12.2",
4142
"eslint-plugin-node": "^6.0.1",
4243
"eslint-plugin-prettier": "^2.6.0",
4344
"express": "~4.13.1",
@@ -47,19 +48,18 @@
4748
"istanbul": "^0.4.5",
4849
"jade": "^1.11.0",
4950
"jade-loader": "~0.8.0",
51+
"jest": "23.0.0-alpha.5",
52+
"jest-silent-reporter": "0.0.4",
5053
"json-loader": "^0.5.7",
5154
"less": "^2.5.1",
5255
"less-loader": "^4.0.3",
5356
"lodash": "^4.17.4",
54-
"mocha": "^3.2.0",
55-
"mocha-lcov-reporter": "^1.0.0",
5657
"prettier": "^1.11.1",
5758
"raw-loader": "~0.5.0",
5859
"react": "^15.2.1",
5960
"react-dom": "^15.2.1",
6061
"rimraf": "^2.6.2",
6162
"script-loader": "~0.7.0",
62-
"should": "^11.1.1",
6363
"simple-git": "^1.65.0",
6464
"sinon": "^2.3.2",
6565
"style-loader": "^0.19.1",
@@ -93,18 +93,17 @@
9393
],
9494
"scripts": {
9595
"setup": "node ./setup/setup.js",
96-
"test": "npm run mocha",
97-
"mocha": "mocha test/*.test.js test/*.unittest.js --max-old-space-size=4096 --harmony --trace-deprecation",
98-
"test:integration": "mocha test/*.test.js --max-old-space-size=4096 --harmony --trace-deprecation",
99-
"test:unit": "mocha test/*.unittest.js --max-old-space-size=4096 --harmony --trace-deprecation",
100-
"travis:integration": "yarn cover:init && yarn cover:integration && yarn cover:report-min",
101-
"travis:unit": "yarn cover:init && yarn cover:unit && yarn cover:report-min",
96+
"test": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest",
97+
"test:integration": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\"",
98+
"test:unit": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
99+
"travis:integration": "yarn cover:init && yarn cover:integration --ci $JEST && yarn cover:report-min",
100+
"travis:unit": "yarn cover:init && yarn cover:unit --ci",
102101
"travis:lint": "yarn lint",
103-
"travis:benchmark": "yarn benchmark",
104-
"appveyor:integration": "yarn cover:init && yarn cover:integration && yarn cover:report-min",
105-
"appveyor:unit": "yarn cover:init && yarn cover:unit && yarn cover:report-min",
106-
"appveyor:benchmark": "yarn benchmark",
107-
"circleci:test": "node node_modules/mocha/bin/mocha --max-old-space-size=4096 --harmony --trace-deprecation test/*.test.js test/*.unittest.js",
102+
"travis:benchmark": "yarn benchmark --ci",
103+
"appveyor:integration": "yarn cover:init && yarn cover:integration --ci %JEST% && yarn cover:report-min",
104+
"appveyor:unit": "yarn cover:init && yarn cover:unit --ci && yarn cover:report-min",
105+
"appveyor:benchmark": "yarn benchmark --ci",
106+
"circleci:test": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --ci",
108107
"circleci:lint": "yarn lint",
109108
"build:examples": "cd examples && node buildAll.js",
110109
"pretest": "yarn lint",
@@ -114,14 +113,54 @@
114113
"type-lint": "tsc --pretty",
115114
"fix": "yarn code-lint --fix",
116115
"pretty": "prettier \"setup/**/*.js\" \"lib/**/*.js\" \"bin/*.js\" \"hot/*.js\" \"buildin/*.js\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\" \"declarations.d.ts\" --write",
117-
"schema-lint": "mocha test/*.lint.js --opts test/lint-mocha.opts",
118-
"benchmark": "mocha --max-old-space-size=4096 --harmony --trace-deprecation test/*.benchmark.js -R spec",
116+
"schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\"",
117+
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
119118
"cover": "yarn cover:init && yarn cover:all && yarn cover:report",
120119
"cover:init": "rimraf coverage",
121-
"cover:all": "node --max-old-space-size=4096 --harmony --trace-deprecation ./node_modules/istanbul/lib/cli.js cover --report none node_modules/mocha/bin/_mocha -- test/*.test.js test/*.unittest.js",
122-
"cover:integration": "node --max-old-space-size=4096 --harmony --trace-deprecation ./node_modules/istanbul/lib/cli.js cover --report none node_modules/mocha/bin/_mocha -- test/*.test.js",
123-
"cover:unit": "node --max-old-space-size=4096 --harmony --trace-deprecation ./node_modules/istanbul/lib/cli.js cover --report none node_modules/mocha/bin/_mocha -- test/*.unittest.js",
120+
"cover:all": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --coverage",
121+
"cover:integration": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\" --coverage",
122+
"cover:unit": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
124123
"cover:report": "istanbul report",
125124
"cover:report-min": "istanbul report --report lcovonly"
125+
},
126+
"jest": {
127+
"setupTestFrameworkScriptFile": "<rootDir>/test/setupTestFramework.js",
128+
"testMatch": [
129+
"<rootDir>/test/*.test.js",
130+
"<rootDir>/test/*.unittest.js"
131+
],
132+
"watchPathIgnorePatterns": [
133+
"<rootDir>/node_modules/webpack/node_modules/",
134+
"<rootDir>/test/js/",
135+
"<rootDir>/test/browsertest/js/",
136+
"<rootDir>/test/fixtures/temp-cache-fixture/",
137+
"<rootDir>/test/fixtures/temp-",
138+
"<rootDir>/benchmark/",
139+
"<rootDir>/examples/*/dist",
140+
"<rootDir>/coverage/"
141+
],
142+
"modulePathIgnorePatterns": [
143+
"<rootDir>/node_modules/webpack/node_modules/",
144+
"<rootDir>/test/js/",
145+
"<rootDir>/test/browsertest/js/",
146+
"<rootDir>/test/fixtures/temp-cache-fixture/",
147+
"<rootDir>/test/fixtures/temp-",
148+
"<rootDir>/benchmark/",
149+
"<rootDir>/examples/*/dist",
150+
"<rootDir>/coverage/"
151+
],
152+
"transformIgnorePatterns": [
153+
"<rootDir>/"
154+
],
155+
"coverageDirectory": "<rootDir>/coverage",
156+
"coveragePathIgnorePatterns": [
157+
"\\.runtime\\.js$",
158+
"<rootDir>/test/",
159+
"<rootDir>/schemas/"
160+
],
161+
"testEnvironment": "node",
162+
"coverageReporters": [
163+
"json"
164+
]
126165
}
127166
}

0 commit comments

Comments
 (0)