Skip to content

Commit 47244cd

Browse files
authored
feat: support jest v27 in vue3-jest (#343)
* test: add typescript e2e test without babel Adds a test close to the setup used by the CLI in a TS project without Babel. The existing TS test was moved to `typescript-with-babel`. The new test is a copy of the older one, with all babel dependencies removed, a rewritten component using the Composition API, a test in TS, a TS config close to the CLI one, and a shim file. * feat: support jest v27 in vue3-jest And also babel-jest and ts-jest v27, for Vue 3. * feat: use TS config to have commonjs modules The previous logic was trying to figure out if CommonJS modules were used in the TS config and if not, and if no babel configuration provided, then loaded a babel transformer to change the module format. This changes the logic to use a more straightforward method by directly updating the tsconfig to commonjs, which should hopefully have the same results without side-effects.
1 parent 9e3b610 commit 47244cd

File tree

19 files changed

+3537
-2368
lines changed

19 files changed

+3537
-2368
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/2.x/custom-transformers/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@babel/core": "^7.9.0",
1515
"@babel/preset-env": "^7.9.0",
1616
"@vue/test-utils": "^1.1.0",
17+
"babel-jest": "^26.6.3",
1718
"jest": "26.x",
1819
"postcss": "^7.0.13",
1920
"postcss-color-function": "^4.0.1",

e2e/3.x/babel-in-package/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
"@babel/preset-env": "^7.9.0",
1515
"@vue/compiler-sfc": "^3.0.3",
1616
"coffeescript": "^2.3.2",
17-
"jest": "^26.0.0",
18-
"ts-jest": "^26.4.4",
17+
"jest": "^27.0.0",
18+
"ts-jest": "^27.0.1",
1919
"typescript": "^4.1.2",
20-
"vue3-jest": "^26.0.0-alpha.10"
20+
"vue3-jest": "^27.0.0-alpha.1"
2121
},
2222
"jest": {
23+
"testEnvironment": "jsdom",
2324
"moduleFileExtensions": [
2425
"js",
2526
"json",

e2e/3.x/basic/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
"babel-plugin-transform-vue-jsx": "^3.7.0",
1919
"coffeescript": "^2.3.2",
2020
"jade": "^1.11.0",
21-
"jest": "^26.0.0",
21+
"jest": "^27.0.0",
2222
"pug": "^2.0.3",
23-
"ts-jest": "^26.4.4",
23+
"ts-jest": "^27.0.1",
2424
"typescript": "^4.1.2",
2525
"vue-class-component": "^8.0.0-beta.4",
26-
"vue3-jest": "^26.0.0-alpha.10",
26+
"vue3-jest": "^27.0.0-alpha.1",
2727
"vue-property-decorator": "^10.0.0-rc.3"
2828
},
2929
"jest": {
30+
"testEnvironment": "jsdom",
3031
"moduleFileExtensions": [
3132
"js",
3233
"json",

e2e/3.x/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/3.x/custom-transformers/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",
1515
"@babel/preset-env": "^7.9.0",
16-
"babel-jest": "^26.0.0",
16+
"babel-jest": "^27.0.0",
1717
"extract-from-css": "^0.4.4",
18-
"jest": "^26.0.0",
18+
"jest": "^27.0.0",
1919
"postcss": "^7.0.13",
2020
"postcss-color-function": "^4.0.1",
2121
"sass": "^1.23.7",
22-
"vue3-jest": "^26.0.0-alpha.10"
22+
"vue3-jest": "^27.0.0-alpha.1"
2323
},
2424
"jest": {
2525
"moduleFileExtensions": [

e2e/3.x/javascript/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
"@babel/core": "^7.9.0",
1414
"@babel/preset-env": "^7.9.0",
1515
"coffeescript": "^2.3.2",
16-
"jest": "^26.0.0",
17-
"vue3-jest": "^26.0.0-alpha.10"
16+
"jest": "^27.0.0",
17+
"vue3-jest": "^27.0.0-alpha.1"
1818
},
1919
"jest": {
20+
"testEnvironment": "jsdom",
2021
"moduleFileExtensions": [
2122
"js",
2223
"json",

e2e/3.x/style/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
"@babel/core": "^7.9.0",
1515
"@babel/preset-env": "^7.9.0",
1616
"@vue/test-utils": "^1.1.0",
17-
"jest": "^26.0.0",
17+
"jest": "^27.0.0",
1818
"less": "^3.9.0",
1919
"postcss": "^7.0.13",
2020
"sass": "^1.23.7",
2121
"stylus": "^0.54.5",
22-
"vue3-jest": "^26.0.0-alpha.10"
22+
"vue3-jest": "^27.0.0-alpha.1"
2323
},
2424
"jest": {
25+
"testEnvironment": "jsdom",
2526
"moduleFileExtensions": [
2627
"js",
2728
"json",

e2e/3.x/typescript-with-babel/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",
1515
"@babel/preset-env": "^7.9.0",
16-
"jest": "^26.0.0",
17-
"ts-jest": "^26.4.4",
16+
"jest": "^27.0.0",
17+
"ts-jest": "^27.0.1",
1818
"typescript": "^4.1.2",
19-
"vue3-jest": "^26.0.0-alpha.10"
19+
"vue3-jest": "^27.0.0-alpha.1"
2020
},
2121
"jest": {
2222
"testEnvironment": "jsdom",

0 commit comments

Comments
 (0)