From a34e75a1c7e0ad3db218ff675eb3d4c7ea95fd9c Mon Sep 17 00:00:00 2001 From: Hunter Laux Date: Mon, 5 Apr 2021 11:28:04 -0700 Subject: [PATCH 1/2] Fix coverage reports for typescript --- lib/transformers/typescript.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/transformers/typescript.js b/lib/transformers/typescript.js index a3b006c3..a3913f77 100644 --- a/lib/transformers/typescript.js +++ b/lib/transformers/typescript.js @@ -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) From 07f22670dfc2f8e69f0edf5fb5a5480ac8cf45ce Mon Sep 17 00:00:00 2001 From: Hunter Laux Date: Mon, 5 Apr 2021 18:32:15 -0700 Subject: [PATCH 2/2] Add unit test for TsSrc --- e2e/__projects__/basic/components/TsSrc.ts | 23 +++++++++++++++++++++ e2e/__projects__/basic/components/TsSrc.vue | 3 +++ e2e/__projects__/basic/test.js | 10 ++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 e2e/__projects__/basic/components/TsSrc.ts create mode 100644 e2e/__projects__/basic/components/TsSrc.vue diff --git a/e2e/__projects__/basic/components/TsSrc.ts b/e2e/__projects__/basic/components/TsSrc.ts new file mode 100644 index 00000000..3aeef17c --- /dev/null +++ b/e2e/__projects__/basic/components/TsSrc.ts @@ -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 + } + } +} diff --git a/e2e/__projects__/basic/components/TsSrc.vue b/e2e/__projects__/basic/components/TsSrc.vue new file mode 100644 index 00000000..c4054806 --- /dev/null +++ b/e2e/__projects__/basic/components/TsSrc.vue @@ -0,0 +1,3 @@ + + + diff --git a/e2e/__projects__/basic/test.js b/e2e/__projects__/basic/test.js index 9269954c..c34d0718 100644 --- a/e2e/__projects__/basic/test.js +++ b/e2e/__projects__/basic/test.js @@ -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' @@ -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) })