Failed parse using external template
See original GitHub issueI used external template like :
<template
src="vue2-simplert-core/simplert.html">
</template>
Success when building production file using vue-loader@13.7.0
.
But unit test failed to run using vue-jest@1.4.0
Here some snippet of my Jest configuration :
"jest": {
"mapCoverage": true,
"coverageDirectory": "test/coverage",
"moduleNameMapper": {
"^vue$": "vue/dist/vue.common.js"
},
"moduleFileExtensions": [
"js",
"vue"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
}
}
Error that I got is :
ENOENT: no such file or directory, open '~/project/src/vue2-simplert-core/simplert.html'
if I look into error message, it because pointing to my project root folder instead of node_modules
folder.
Is there any missing from my side ?
Thanks for all response 👍
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Why doesn't template.ParseFiles() detect this error?
ParseFiles () doesn't report missing templates, because often not all the templates are parsed in a single step, and reporting missing templates ......
Read more >Common CSV Template Error Messages and How to Fix Them
An error message that begins “Failed to parse file” indicates that the uploaded CSV file is invalid in some way. Watershed supports UTF-8 ......
Read more >PARSE - IBM
If the external data queue is empty, PARSE PULL reads a line from the default input stream (the user's terminal), and the program...
Read more >13.2 Parsing HTML documents - HTML Standard - whatwg
This error occurs if the parser encounters an attribute in a tag that already has an attribute with the same name. The parser...
Read more >Troubleshooting in Athena - AWS Documentation
The OpenX JSON SerDe throws this error when it fails to parse a column in an ... This error occurs when you use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello guys. We have a project that is in a similar situation. This is part of our Webpack configuration (aliases section):
As we can see, each alias is a reference to the “src” directory. And this is how we use them in vue files:
OK, to use Jest we need to replicate the above case in a configuration. This is how it looks:
And the result after the transformation from “vue-jest” is:
ENOENT, no such file or directory
Which is absolutely logical, judging by these lines of code in “vue-jest/lib/process”:
To the authors: You need to rethink your code to cover cases like ours. moduleNameMapper is useless in the above case if you think it will be useful.
WORKAROUND
We created a file (vue-jest.js) that replicates the function from “vue-jest/lib/process” with the following content:
Then in the jest configuration, we just refer to this file:
Now it works like a charm! I hope it helps someone.
This is a problem on our side we need to fix. At the moment, we only look for a src that is relative, not in node_modules
Thanks for bring it to my attention, I’ll look to get a fix in place 🙂