Skip to content

Commit af80ab0

Browse files
authored
Fix coverage reports for typescript for vue3 (#331)
* Fix coverage reports for typescript * Add unit test for TsSrc
1 parent acab463 commit af80ab0

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default {
2+
name: 'basic',
3+
computed: {
4+
headingClasses: function headingClasses() {
5+
return {
6+
red: this.isCrazy,
7+
blue: !this.isCrazy,
8+
shadow: this.isCrazy
9+
}
10+
}
11+
},
12+
data: function data() {
13+
return {
14+
msg: 'Welcome to Your Vue.js App',
15+
isCrazy: false
16+
}
17+
},
18+
methods: {
19+
toggleClass: function toggleClass() {
20+
this.isCrazy = !this.isCrazy
21+
}
22+
}
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template src="./BasicSrc.html"></template>
2+
3+
<script lang="ts" src="./TsSrc.ts"></script>

e2e/__projects__/basic/test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { resolve } from 'path'
33
import { readFileSync } from 'fs'
44

55
import BasicSrc from './components/BasicSrc.vue'
6+
import TsSrc from './components/TsSrc.vue'
67
import Pug from './components/Pug.vue'
78
import Coffee from './components/Coffee.vue'
89
import Basic from './components/Basic.vue'
@@ -47,13 +48,20 @@ test('processes .vue files', () => {
4748
)
4849
})
4950

50-
test('processes .vue files with src attributes', () => {
51+
test('processes .vue files with js src attributes', () => {
5152
mount(BasicSrc)
5253
expect(document.querySelector('h1').textContent).toBe(
5354
'Welcome to Your Vue.js App'
5455
)
5556
})
5657

58+
test('processes .vue files with ts src attributes', () => {
59+
mount(TsSrc)
60+
expect(document.querySelector('h1').textContent).toBe(
61+
'Welcome to Your Vue.js App'
62+
)
63+
})
64+
5765
test('handles named exports', () => {
5866
expect(randomExport).toEqual(42)
5967
})

lib/transformers/typescript.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ module.exports = {
1616
const tsconfig = getTsJestConfig(config)
1717
const babelOptions = getBabelOptions(filePath)
1818

19-
const res = typescript.transpileModule(scriptContent, tsconfig)
19+
const res = typescript.transpileModule(scriptContent, {
20+
...tsconfig,
21+
fileName: filePath
22+
})
2023

2124
res.outputText = stripInlineSourceMap(res.outputText)
2225

0 commit comments

Comments
 (0)