https://cypress.io logo
Import file outside of cypress not working
# i-need-help
s
I've exported an object from our .vue file but cannot get Cypress to find it. What's the correct up-to-date way of doing this? I've tried adding this
import { icons } from '../../../folder/folder2/folder3/file.vue'
but get errors stating
Module not found /component-tests/e2e/Atoms/folder/folder2/folder3/file.vue
I've tried a few other ways too, but always end up with this error. It's looking within the cypress directory only and not stepping back out as I expect it to.
h
Can you show your project folder structure - including your test file and the
file.vue
?
s
Apologies in advance, I'm not sure how to make it pretty looking: root -component-tests -e2e -Atoms -Icon -File I'm trying to import the vue file
root -src -components -atoms -icon -file.vue that I've done an export
so src and component-tests are on the same level in the structure
h
Emm, in your IDE, when you are focused on the test module and then you right click that target module
file.vue
, there should be "Copy relative path" option in context menu
It should give you correct path
Or try going one level up from where it's failing
s
Yeah I tried that - but no luck. I'm wondering if it's my cypress tsconfig.json setup (I've not clue about that file). Problem seems to be is Cypress won't go up a directory, like it's ignoring ../../ and so on. It's a pain lol
h
Maybe path alias could help?
If you would declare an alias for a root path and use at the beginning of imported module path
s
ooo nice - I'll google and have a look at that 👍 thanks
awesome - that's found the vue file!! I've got a Webpack compilation error now
Module parse failed: Unexpected token (1:0)
the .vue file is a template.
But I've had enough for this week - that's going to be a problem for Monday's RustyBeer 😉
6 Views