Skip to content

Commit fdf77e2

Browse files
committed
feat: support jest v27
And also babel-jest and ts-jest v27.
1 parent d086ee5 commit fdf77e2

File tree

16 files changed

+815
-631
lines changed

16 files changed

+815
-631
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/node:10.16.3
5+
- image: circleci/node:10.24.1
66

77
working_directory: ~/repo
88

e2e/__projects__/babel-in-package/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
"dependencies": {
1111
"@babel/core": "^7.9.0",
1212
"@babel/preset-env": "^7.9.0",
13-
"jest": "^26.0.0",
14-
"ts-jest": "^26.4.4",
13+
"jest": "^27.0.0",
14+
"ts-jest": "^27.0.0",
1515
"typescript": "^4.1.2",
1616
"vue": "^3.0.3"
1717
},
1818
"jest": {
19+
"testEnvironment": "jsdom",
1920
"moduleFileExtensions": [
2021
"js",
2122
"json",

e2e/__projects__/basic/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
"babel-helper-vue-jsx-merge-props": "^2.0.3",
1818
"babel-plugin-syntax-jsx": "^6.18.0",
1919
"babel-plugin-transform-vue-jsx": "^3.7.0",
20-
"jest": "^26.0.0",
21-
"ts-jest": "^26.4.4",
20+
"jest": "^27.0.0",
21+
"ts-jest": "^27.0.1",
2222
"typescript": "^4.1.2",
2323
"vue-class-component": "^8.0.0-beta.4",
2424
"vue-property-decorator": "^10.0.0-rc.3"
2525
},
2626
"jest": {
27+
"testEnvironment": "jsdom",
2728
"moduleFileExtensions": [
2829
"js",
2930
"json",

e2e/__projects__/basic/test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,23 @@ test('handles named exports', () => {
7272
test('generates source maps for .vue files', () => {
7373
const filePath = resolve(__dirname, './components/Basic.vue')
7474
const fileString = readFileSync(filePath, { encoding: 'utf8' })
75-
76-
const { code } = jestVue.process(fileString, filePath, {
75+
const config = {
7776
moduleFileExtensions: ['js', 'vue']
78-
})
77+
}
78+
79+
const { code } = jestVue.process(fileString, filePath, { config })
7980

8081
expect(code).toMatchSnapshot()
8182
})
8283

8384
test('generates source maps using src attributes', () => {
8485
const filePath = resolve(__dirname, './components/SourceMapsSrc.vue')
8586
const fileString = readFileSync(filePath, { encoding: 'utf8' })
86-
87-
const { code } = jestVue.process(fileString, filePath, {
87+
const config = {
8888
moduleFileExtensions: ['js', 'vue']
89-
})
89+
}
90+
91+
const { code } = jestVue.process(fileString, filePath, { config })
9092

9193
expect(code).toMatchSnapshot()
9294
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { createTransformer } = require('babel-jest')
1+
const { createTransformer } = require('babel-jest').default
22
module.exports = createTransformer({
33
presets: ['@babel/preset-env']
44
})

e2e/__projects__/custom-transformers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"devDependencies": {
1515
"@babel/core": "^7.9.0",
1616
"@babel/preset-env": "^7.9.0",
17-
"jest": "^26.0.0",
17+
"jest": "^27.0.0",
1818
"postcss": "^7.0.13",
1919
"postcss-color-function": "^4.0.1",
2020
"sass": "^1.23.7"

e2e/__projects__/javascript/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",
1515
"@babel/preset-env": "^7.9.0",
16-
"jest": "^26.0.0"
16+
"jest": "^27.0.0"
1717
},
1818
"jest": {
19+
"testEnvironment": "jsdom",
1920
"moduleFileExtensions": [
2021
"js",
2122
"json",

e2e/__projects__/style/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@babel/core": "^7.9.0",
1616
"@babel/preset-env": "^7.9.0",
1717
"@vue/test-utils": "^1.1.0",
18-
"jest": "^26.0.0",
18+
"jest": "^27.0.0",
1919
"postcss": "^7.0.13",
2020
"sass": "^1.23.7"
2121
},

e2e/__projects__/typescript/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",
1515
"@babel/preset-env": "^7.9.0",
16-
"jest": "^26.0.0"
16+
"jest": "^27.0.0"
1717
},
1818
"jest": {
1919
"globals": {
2020
"vue-jest": {
2121
"tsConfig": "./sub-project/tsconfig.json"
2222
}
2323
},
24+
"testEnvironment": "jsdom",
2425
"moduleFileExtensions": [
2526
"js",
2627
"json",

lib/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
const crypto = require('crypto')
2-
const babelJest = require('babel-jest')
3-
2+
const babelJest = require('babel-jest').default
43
module.exports = {
54
process: require('./process'),
65
getCacheKey: function getCacheKey(
76
fileData,
87
filename,
9-
configString,
10-
{ config, instrument, rootDir }
8+
{ config, configString, instrument, rootDir }
119
) {
1210
return crypto
1311
.createHash('md5')
1412
.update(
15-
babelJest.getCacheKey(fileData, filename, configString, {
13+
babelJest.getCacheKey(fileData, filename, {
1614
config,
15+
configString,
1716
instrument,
1817
rootDir
1918
}),

0 commit comments

Comments
 (0)