Unable to use alias
to stub PNGs inside a module
#3809
Replies: 8 comments 4 replies
-
Alias is relative to the file the import is located in. Use absolute paths in |
Beta Was this translation helpful? Give feedback.
-
@sheremet-va I tried that, still couldn't get it to mock it ever, no matter which versions I tried alias: {
'@some_module/framework/static/images/icon.png': 'foo',
'node_modules/@some_module/framework/static/images/icon.png': 'foo',
'./node_modules/@some_module/framework/static/images/icon.png': 'foo',
} Nothing seemed to change so my assumption was, it still wasn't mocking anything. |
Beta Was this translation helpful? Give feedback.
-
You can use array syntax with find option as a regexp. This alias is applied to imports that are written in your source code and not to resolved files, so you don't need to reference node_modules.
|
Beta Was this translation helpful? Give feedback.
-
Hello, I have a similar issue where I use a package that has a component that imports a gif.
When I click on it I'm redirected to the following line:
The funny part is that it doesn't seem that the rendered parent component is even using that, so it makes things even weirder. Any idea what can be the cause of that issue? |
Beta Was this translation helpful? Give feedback.
-
bump this. same issue for importing font deep in libraries SemiBold_ttf=require("@uikit/fonts/SemiBold.ttf") |
Beta Was this translation helpful? Give feedback.
-
seems to be related #1910 |
Beta Was this translation helpful? Give feedback.
-
Did anyone find a solution for that already? |
Beta Was this translation helpful? Give feedback.
-
I'm also facing this issue and I solved it by downgrading Vitest to v0.33.0 For me, this issue started appearing on v0.34.0 ahead. As far as I could notice, there was a change in how we config the Update: I managed to fix this by updating a bunch of dependencies altogether ✌️ |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
My library imports another library that has a component that includes a PNG file. This is causing a
SyntaxError: Invalid or unexpected token
on Vitest on my library.This is the bit that causes the error. I've tried aliasing it
But I'm not convinced it is paying any attention to that mock. Am I missing something?
Reproduction
Set up a library with a component like
Import that library and try to test any component.
System Info
Beta Was this translation helpful? Give feedback.
All reactions