Skip to content

Commit

Permalink
fix: fix typo in jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Jan 2, 2019
1 parent 0fc972e commit 4feaacf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,47 @@ test('should work without Babel', async () => {
})
await project.run(`vue-cli-service test:unit`)
})

test('should work with tsx', async () => {
const { write, run } = await create('jest-with-tsx', {
plugins: {
'@vue/cli-plugin-babel': {},
'@vue/cli-plugin-typescript': {
useTsWithBabel: true,
classComponent: true
},
'@vue/cli-plugin-unit-jest': {}
},
useConfigFiles: true
})

await write('src/components/HelloWorld.tsx', `
import { Component, Prop, Vue } from 'vue-property-decorator';
@Component
export default class HelloWorld extends Vue {
@Prop() private msg!: string;
render () {
return <div>{this.msg}</div>
}
}
`)

await write('tests/unit/example.spec.ts', `
import { shallowMount } from '@vue/test-utils'
import MyComponent from '@/components/HelloWorld.tsx'
describe('HelloWorld.tsx', () => {
it('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(MyComponent, {
propsData: { msg }
})
expect(wrapper.text()).toMatch(msg)
})
})
`)

await run(`vue-cli-service test:unit`)
})
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-jest/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const applyTS = module.exports.applyTS = (api, invoking) => {
if (api.hasPlugin('babel')) {
api.extendPackage({
jest: {
global: {
globals: {
'ts-jest': {
// we need babel to transpile JSX
babelConfig: true
Expand Down

0 comments on commit 4feaacf

Please sign in to comment.