From 7592dfbf7f429e328938263ddbf574e7f0758ea3 Mon Sep 17 00:00:00 2001 From: Jakub Freisler Date: Mon, 28 Sep 2020 20:53:16 +0200 Subject: [PATCH 1/2] test: template string within the HTML template --- .../basic/components/TemplateString.vue | 21 +++++++++++++++++++ e2e/__projects__/basic/package.json | 7 +++++++ e2e/__projects__/basic/test.js | 10 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 e2e/__projects__/basic/components/TemplateString.vue diff --git a/e2e/__projects__/basic/components/TemplateString.vue b/e2e/__projects__/basic/components/TemplateString.vue new file mode 100644 index 00000000..7454d234 --- /dev/null +++ b/e2e/__projects__/basic/components/TemplateString.vue @@ -0,0 +1,21 @@ + + + diff --git a/e2e/__projects__/basic/package.json b/e2e/__projects__/basic/package.json index 0ed65a1a..d6cbbcb1 100644 --- a/e2e/__projects__/basic/package.json +++ b/e2e/__projects__/basic/package.json @@ -38,6 +38,13 @@ "vue-jest": { "pug": { "basedir": "./" + }, + "templateCompiler": { + "transpileOptions": { + "transforms": { + "dangerousTaggedTemplateString": true + } + } } } } diff --git a/e2e/__projects__/basic/test.js b/e2e/__projects__/basic/test.js index 20adeb87..51a5bc2b 100644 --- a/e2e/__projects__/basic/test.js +++ b/e2e/__projects__/basic/test.js @@ -1,5 +1,6 @@ import { mount } from '@vue/test-utils' import TypeScript from './components/TypeScript.vue' +import TemplateString from './components/TemplateString.vue' import { resolve } from 'path' import { readFileSync } from 'fs' import jestVue from 'vue-jest' @@ -81,6 +82,15 @@ test('processes .vue files with lang set to typescript', () => { expect(wrapper.element.tagName).toBe('DIV') }) +test('processes .vue files with template strings in the template', () => { + const wrapper = mount(TemplateString) + expect(wrapper.attributes('data-sth')).toBe(` + query { + id + } + `) +}) + test('processes functional components', () => { const clickSpy = jest.fn() const wrapper = mount(FunctionalSFC, { From 37efa5873661385c1a979838b23b72701650a132 Mon Sep 17 00:00:00 2001 From: Jakub Freisler Date: Mon, 28 Sep 2020 21:28:16 +0200 Subject: [PATCH 2/2] feat: pass templateCompiler options --- lib/process.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/process.js b/lib/process.js index bdd00e37..1a462dc5 100644 --- a/lib/process.js +++ b/lib/process.js @@ -57,16 +57,21 @@ function processTemplate(template, filename, config) { template.content = loadSrc(template.src, filename) } + const userTemplateCompilerOptions = vueJestConfig.templateCompiler || {} const result = compilerUtils.compileTemplate({ source: template.content, compiler: VueTemplateCompiler, filename: filename, - compilerOptions: { - optimize: false - }, isFunctional: template.attrs.functional, preprocessLang: template.lang, - preprocessOptions: vueJestConfig[template.lang] + preprocessOptions: vueJestConfig[template.lang], + ...userTemplateCompilerOptions, + compilerOptions: { + optimize: false, + ...userTemplateCompilerOptions.compilerOptions + }, + transformAssetUrls: { ...userTemplateCompilerOptions.transformAssetUrls }, + transpileOptions: { ...userTemplateCompilerOptions.transpileOptions } }) logResultErrors(result) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy