Skip to content

Commit 4feaacf

Browse files
committed
fix: fix typo in jest config
1 parent 0fc972e commit 4feaacf

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,47 @@ test('should work without Babel', async () => {
6767
})
6868
await project.run(`vue-cli-service test:unit`)
6969
})
70+
71+
test('should work with tsx', async () => {
72+
const { write, run } = await create('jest-with-tsx', {
73+
plugins: {
74+
'@vue/cli-plugin-babel': {},
75+
'@vue/cli-plugin-typescript': {
76+
useTsWithBabel: true,
77+
classComponent: true
78+
},
79+
'@vue/cli-plugin-unit-jest': {}
80+
},
81+
useConfigFiles: true
82+
})
83+
84+
await write('src/components/HelloWorld.tsx', `
85+
import { Component, Prop, Vue } from 'vue-property-decorator';
86+
87+
@Component
88+
export default class HelloWorld extends Vue {
89+
@Prop() private msg!: string;
90+
91+
render () {
92+
return <div>{this.msg}</div>
93+
}
94+
}
95+
`)
96+
97+
await write('tests/unit/example.spec.ts', `
98+
import { shallowMount } from '@vue/test-utils'
99+
import MyComponent from '@/components/HelloWorld.tsx'
100+
101+
describe('HelloWorld.tsx', () => {
102+
it('renders props.msg when passed', () => {
103+
const msg = 'new message'
104+
const wrapper = shallowMount(MyComponent, {
105+
propsData: { msg }
106+
})
107+
expect(wrapper.text()).toMatch(msg)
108+
})
109+
})
110+
`)
111+
112+
await run(`vue-cli-service test:unit`)
113+
})

packages/@vue/cli-plugin-unit-jest/generator/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const applyTS = module.exports.applyTS = (api, invoking) => {
8989
if (api.hasPlugin('babel')) {
9090
api.extendPackage({
9191
jest: {
92-
global: {
92+
globals: {
9393
'ts-jest': {
9494
// we need babel to transpile JSX
9595
babelConfig: true

0 commit comments

Comments
 (0)