Skip to content

Failed parse using external (relative) template #176

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

Closed
laggingreflex opened this issue May 3, 2019 · 3 comments
Closed

Failed parse using external (relative) template #176

laggingreflex opened this issue May 3, 2019 · 3 comments
Labels

Comments

@laggingreflex
Copy link

Similar (but slightly different) to #45

Using relative templates but I still have an issue. The templates do get parsed, but I think they're not "interpreted" correctly.

Repro: https://github.com/laggingreflex/repro-vue-jest-template

It works in the browser but running jest it gives this error

> jest
Cannot use <template> as component root element because it may contain multiple nodes.
 FAIL  src/test.js
  ● Test suite failed to run

Taking hint from the error, if I change my App/template.vue from

<template>
  <div>App</div>
</template>

to just

  <div>App</div>

the test passes, but that's not the correct format for template - the app doesn't work in the browser.

@LinusBorg
Copy link
Member

but that's not the correct format for template

Well, the external file that you include should be .html, not .vue

<template src="./template.html">

including another .vue file was never a use case for SFCs.

@eddyerburgh
Copy link
Member

As @LinusBorg says, external .vue files aren't part of the SFC spec

@TheCeloReis
Copy link

TheCeloReis commented Sep 6, 2021

@eddyerburgh I'm switching to .html files for a fix, but I think vue-jest should consider adding support to .vue external templates

  • vue-template-compiler compiles external .vue files, vue-jest should also, otherwise we can end up with a bunch of broken tests.
  • For sure, it's not part of the SFC spec, but it would be a nice increment, using the template file as .vue provides better IDE support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants