Skip to content

Commit dfacba6

Browse files
authored
build: migrate tests to jest (#1738)
* build: migrate tests to jest * build: remove babel object-rest-spread plugin * chore: rename `.eslintrc` to `.eslintrc.json` * chore: update `.eslintrc` in the test folder too
1 parent 71372c3 commit dfacba6

22 files changed

+2346
-743
lines changed

.babelrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"presets": ["env"],
3-
"plugins": ["transform-object-rest-spread"]
2+
"presets": ["@babel/preset-env"]
43
}
File renamed without changes.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/coverage
12
/docs/.vuepress/dist
23
/examples/**/build.js
34
/test/e2e/reports

examples/chat/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'babel-polyfill'
21
import Vue from 'vue'
32
import App from './components/App.vue'
43
import store from './store'

examples/counter/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'babel-polyfill'
21
import Vue from 'vue'
32
import Counter from './Counter.vue'
43
import store from './store'

examples/shopping-cart/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'babel-polyfill'
21
import Vue from 'vue'
32
import App from './components/App.vue'
43
import store from './store'

examples/todomvc/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'babel-polyfill'
21
import Vue from 'vue'
32
import store from './store'
43
import App from './components/App.vue'

jest.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
rootDir: __dirname,
3+
globals: {
4+
__DEV__: true
5+
},
6+
moduleNameMapper: {
7+
'^@/(.*)$': '<rootDir>/src/$1',
8+
'^test/(.*)$': '<rootDir>/test/$1'
9+
},
10+
testMatch: ['<rootDir>/test/unit/**/*.spec.js'],
11+
testPathIgnorePatterns: ['/node_modules/'],
12+
setupFilesAfterEnv: [
13+
'./test/setup.js'
14+
],
15+
"transform": {
16+
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
17+
},
18+
coverageDirectory: 'coverage',
19+
coverageReporters: ['json', 'lcov', 'text-summary', 'clover'],
20+
collectCoverageFrom: [
21+
'src/**/*.js',
22+
'!src/index.cjs.js'
23+
]
24+
}

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
"build:logger": "node scripts/build-logger.js",
2222
"lint": "eslint src test",
2323
"test": "npm run lint && npm run test:types && npm run test:unit && npm run test:ssr && npm run test:e2e",
24-
"test:unit": "jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
24+
"test:unit": "jest --testPathIgnorePatterns test/e2e",
2525
"test:e2e": "node test/e2e/runner.js",
26-
"test:ssr": "cross-env VUE_ENV=server jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
26+
"test:ssr": "cross-env VUE_ENV=server jest --testPathIgnorePatterns test/e2e",
2727
"test:types": "tsc -p types/test",
28+
"coverage": "jest --testPathIgnorePatterns test/e2e --coverage",
2829
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
2930
"release": "node scripts/release.js",
3031
"docs": "vuepress dev docs",
@@ -44,16 +45,15 @@
4445
"vue": "^2.0.0"
4546
},
4647
"devDependencies": {
48+
"@babel/core": "^7.9.0",
49+
"@babel/preset-env": "^7.9.5",
4750
"@rollup/plugin-buble": "^0.21.3",
4851
"@rollup/plugin-commonjs": "^11.1.0",
4952
"@rollup/plugin-node-resolve": "^7.1.3",
5053
"@rollup/plugin-replace": "^2.3.2",
5154
"@types/node": "^13.13.2",
52-
"babel-core": "^6.22.1",
53-
"babel-loader": "^7.1.2",
54-
"babel-plugin-transform-object-rest-spread": "^6.23.0",
55-
"babel-polyfill": "^6.22.0",
56-
"babel-preset-env": "^1.5.1",
55+
"babel-jest": "^25.4.0",
56+
"babel-loader": "^8.1.0",
5757
"brotli": "^1.3.2",
5858
"chalk": "^4.0.0",
5959
"chromedriver": "^80.0.1",
@@ -66,10 +66,10 @@
6666
"eslint-plugin-vue-libs": "^4.0.0",
6767
"execa": "^4.0.0",
6868
"express": "^4.17.1",
69-
"jasmine": "2.8.0",
70-
"jasmine-core": "2.8.0",
69+
"jest": "^25.4.0",
7170
"nightwatch": "^1.3.1",
7271
"nightwatch-helpers": "^1.2.0",
72+
"regenerator-runtime": "^0.13.5",
7373
"rollup": "^2.7.2",
7474
"rollup-plugin-terser": "^5.3.0",
7575
"semver": "^7.3.2",

test/.eslintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"jest": true
4+
}
5+
}

0 commit comments

Comments
 (0)