Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverage reports for typescript for vue3 #331

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions e2e/__projects__/basic/components/TsSrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default {
name: 'basic',
computed: {
headingClasses: function headingClasses() {
return {
red: this.isCrazy,
blue: !this.isCrazy,
shadow: this.isCrazy
}
}
},
data: function data() {
return {
msg: 'Welcome to Your Vue.js App',
isCrazy: false
}
},
methods: {
toggleClass: function toggleClass() {
this.isCrazy = !this.isCrazy
}
}
}
3 changes: 3 additions & 0 deletions e2e/__projects__/basic/components/TsSrc.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template src="./BasicSrc.html"></template>

<script lang="ts" src="./TsSrc.ts"></script>
10 changes: 9 additions & 1 deletion e2e/__projects__/basic/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { resolve } from 'path'
import { readFileSync } from 'fs'

import BasicSrc from './components/BasicSrc.vue'
import TsSrc from './components/TsSrc.vue'
import Pug from './components/Pug.vue'
import Coffee from './components/Coffee.vue'
import Basic from './components/Basic.vue'
Expand Down Expand Up @@ -46,13 +47,20 @@ test('processes .vue files', () => {
)
})

test('processes .vue files with src attributes', () => {
test('processes .vue files with js src attributes', () => {
mount(BasicSrc)
expect(document.querySelector('h1').textContent).toBe(
'Welcome to Your Vue.js App'
)
})

test('processes .vue files with ts src attributes', () => {
mount(TsSrc)
expect(document.querySelector('h1').textContent).toBe(
'Welcome to Your Vue.js App'
)
})

test('handles named exports', () => {
expect(randomExport).toEqual(42)
})
Expand Down
5 changes: 4 additions & 1 deletion lib/transformers/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ module.exports = {
const tsconfig = getTsJestConfig(config)
const babelOptions = getBabelOptions(filePath)

const res = typescript.transpileModule(scriptContent, tsconfig)
const res = typescript.transpileModule(scriptContent, {
...tsconfig,
fileName: filePath
})

res.outputText = stripInlineSourceMap(res.outputText)

Expand Down