Skip to content

Commit 630c526

Browse files
committed
Merge branch 'master' of github.com:vuejs/vue-jest
2 parents 980ae73 + 3a0f4fe commit 630c526

File tree

22 files changed

+171
-1274
lines changed

22 files changed

+171
-1274
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
"@babel/preset-env": "^7.9.0",
1717
"@vue/test-utils": "^1.1.0",
1818
"coffeescript": "^2.3.2",
19-
"jest": "26.x",
20-
"ts-jest": "^26.3.0",
19+
"jest": "27.x",
20+
"ts-jest": "^27.0.4",
2121
"typescript": "^3.2.2",
22-
"vue2-jest": "~26.0.0"
22+
"vue2-jest": "~27.0.0-alpha.1"
2323
},
2424
"jest": {
25+
"testEnvironment": "jsdom",
2526
"moduleFileExtensions": [
2627
"js",
2728
"json",

e2e/2.x/basic/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
"babel-plugin-transform-vue-jsx": "^3.7.0",
2020
"coffeescript": "^2.3.2",
2121
"jade": "^1.11.0",
22-
"jest": "26.x",
22+
"jest": "27.x",
2323
"pug": "^3.0.1",
2424
"sass": "^1.23.7",
25-
"ts-jest": "^26.3.0",
25+
"ts-jest": "^27.0.4",
2626
"typescript": "^3.2.2",
27-
"vue2-jest": "~26.0.0"
27+
"vue2-jest": "~27.0.0-alpha.1"
2828
},
2929
"jest": {
30+
"testEnvironment": "jsdom",
3031
"moduleFileExtensions": [
3132
"js",
3233
"json",

e2e/2.x/basic/test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ test('handles named exports', () => {
3838
test('generates source maps for .vue files', () => {
3939
const filePath = resolve(__dirname, './components/Basic.vue')
4040
const fileString = readFileSync(filePath, { encoding: 'utf8' })
41+
const config = {
42+
moduleFileExtensions: ['js', 'vue']
43+
}
4144

4245
const { map } = jestVue.process(fileString, filePath, {
43-
moduleFileExtensions: ['js', 'vue']
46+
config
4447
})
4548

4649
expect(map).toMatchSnapshot()
@@ -50,8 +53,12 @@ test('generates source maps using src attributes', () => {
5053
const filePath = resolve(__dirname, './components/SourceMapsSrc.vue')
5154
const fileString = readFileSync(filePath, { encoding: 'utf8' })
5255

53-
const { map } = jestVue.process(fileString, filePath, {
56+
const config = {
5457
moduleFileExtensions: ['js', 'vue']
58+
}
59+
60+
const { map } = jestVue.process(fileString, filePath, {
61+
config
5562
})
5663

5764
expect(map).toMatchSnapshot()
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/2.x/custom-transformers/package.json

Lines changed: 4 additions & 3 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-
"babel-jest": "^26.6.3",
18-
"jest": "26.x",
17+
"babel-jest": "^27.0.6",
18+
"jest": "27.x",
1919
"postcss": "^7.0.13",
2020
"postcss-color-function": "^4.0.1",
2121
"sass": "^1.23.7",
22-
"vue2-jest": "~26.0.0"
22+
"vue2-jest": "~27.0.0-alpha.1"
2323
},
2424
"jest": {
25+
"testEnvironment": "jsdom",
2526
"moduleFileExtensions": [
2627
"js",
2728
"json",

e2e/2.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.x",
17+
"jest": "27.x",
1818
"less": "^3.9.0",
1919
"postcss": "^7.0.13",
2020
"sass": "^1.23.7",
2121
"stylus": "^0.54.5",
22-
"vue2-jest": "~26.0.0"
22+
"vue2-jest": "~27.0.0-alpha.1"
2323
},
2424
"jest": {
25+
"testEnvironment": "jsdom",
2526
"moduleFileExtensions": [
2627
"js",
2728
"json",

e2e/3.x/custom-transformers/components/Scss.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
3-
<span :class="this.$style.g"></span>
4-
<span :class="this.$style.dark.f"></span>
3+
<span :class="$style.g"></span>
4+
<span :class="$style.dark.f"></span>
55
</div>
66
</template>
77

e2e/3.x/custom-transformers/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",
1515
"@babel/preset-env": "^7.9.0",
16+
"@vue/test-utils": "^2.0.0-rc.10",
1617
"babel-jest": "^27.0.0",
1718
"extract-from-css": "^0.4.4",
1819
"jest": "^27.0.0",
@@ -22,6 +23,7 @@
2223
"vue3-jest": "^27.0.0-alpha.1"
2324
},
2425
"jest": {
26+
"testEnvironment": "jsdom",
2527
"moduleFileExtensions": [
2628
"js",
2729
"json",

e2e/3.x/custom-transformers/test.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
// import { createApp, h } from 'vue'
2-
3-
// import Scss from './components/Scss.vue'
4-
5-
// function mount(Component, props, slots) {
6-
// document.getElementsByTagName('html')[0].innerHTML = ''
7-
// const el = document.createElement('div')
8-
// el.id = 'app'
9-
// document.body.appendChild(el)
10-
// const Parent = {
11-
// render() {
12-
// return h(Component, props, slots)
13-
// }
14-
// }
15-
// createApp(Parent).mount(el)
16-
// }
17-
18-
// TODO: Figure this out with Vue 3. `$style` no longer exists.
19-
test.todo('processes SCSS using user specified post transforms')
20-
21-
test.todo('processes SCSS using user specified pre transforms')
1+
import { mount } from '@vue/test-utils'
2+
import Scss from './components/Scss.vue'
3+
4+
test('processes SCSS using user specified post transforms', () => {
5+
const wrapper = mount(Scss)
6+
expect(wrapper.vm.$style.light.a).toBeUndefined()
7+
expect(wrapper.vm.$style.light.f).toEqual('f')
8+
expect(wrapper.vm.$style.dark.f).toEqual('f')
9+
expect(wrapper.vm.$style.dark.g).toEqual('g')
10+
})
11+
12+
test('processes SCSS using user specified pre transforms', () => {
13+
const wrapper = mount(Scss)
14+
expect(wrapper.vm.$style.g).toEqual('g')
15+
})

e2e/3.x/style/components/External.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
<style module src="./styles/external.css" />
88

9+
<style module="$style2" src="~__styles/external.css" />
10+
11+
<style module="$style3" src="./styles/external.css"></style>
12+
913
<style module="css">
1014
.a {
1115
background: color(red a(90%));

0 commit comments

Comments
 (0)