@@ -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+ } )
0 commit comments