You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request
Current behavior
Multiple file components such as components/HelloWorld/ cannot import files
relatively in jest if the script is in a subfolder:
<scriptsrc="./script/index.js"></script>
Because inside the script, if we do the following:
import{greeter}from'./lib/something'
Jest will throw the following error looking for lib/something because it
looks for the file relative to index.vue instead of script/index.js.
FAIL test/unit/specs/HelloWorld.spec.js
● Test suite failed to run
Cannot find module './lib/something' from 'index.vue'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:191:17)
at src/components/HelloWorld/index.vue:8:18
at Object.<anonymous> (src/components/HelloWorld/index.vue:18:3)
Current fix is to not put index.js inside a subfolder. Alternatively, the following can be done:
Files imported inside a script should be relative to the script path instead of the index.vue file.
The workaround shouldn't be necessary (or should be documented).
Minimal reproduction of the problem with instructions
I've created a test repo here
Do npm install
Running npm run start works just fine
Running npm run test will throw the error
(I hope this is sufficient, and that my suspicion for origin of behaviour is correct)
What is the motivation / use case for changing the behavior?
Avoid using the workaround as it works as is with Webpack.
I'm submitting a ... (check one with "x")
Current behavior
Multiple file components such as
components/HelloWorld/
cannot import filesrelatively in
jest
if the script is in a subfolder:Because inside the script, if we do the following:
Jest will throw the following error looking for
lib/something
because itlooks for the file relative to
index.vue
instead ofscript/index.js
.Current fix is to not put
index.js
inside a subfolder. Alternatively, the following can be done:Expected behavior
Files imported inside a script should be relative to the script path instead of the
index.vue
file.The workaround shouldn't be necessary (or should be documented).
Minimal reproduction of the problem with instructions
I've created a test repo here
npm install
npm run start
works just finenpm run test
will throw the error(I hope this is sufficient, and that my suspicion for origin of behaviour is correct)
What is the motivation / use case for changing the behavior?
Avoid using the workaround as it works as is with Webpack.
Please tell us about your environment:
Node version : [ OSX | Linux | Windows ]
v9.3.0
Platform: [ OSX | Linux | Windows ]
Linux
The text was updated successfully, but these errors were encountered: