Closed xFeXx closed 1 year ago
Nevermind, I got it running with: '^.*\\.(svg)(\\?url)$': '<rootDir>/configs/tests/__mocks__/svgUrlMock.ts',
svgUrlMock.ts:
export default 'test.svg'
Hi, I have the same issue but I'm using react.js. Is there any special setting in the "svgrUrlMock.ts" file that you use? thanks a lot...
My file just a basic export:
export default 'test.svg'
First of all, thank you for your work! It really helped a lot while reworking a whole project with vue3 and vite. While testing with only importing without any prefix I could get it running. But I stumbled across a problem while unit testing my components. I imported a svg in order to use it as a background-image:
In dev and prod build everything runs fine, but the test keeps failing. I tried the approach from here: https://github.com/jpkleemans/vite-svg-loader/issues/35 My
jest.config.js
looks like this:I know the problem is
'.+\\.(svg?url)$': '<rootDir>/configs/tests/__mocks__/svgUrlMock.ts',
, but I can't find a working solution. Is there a clever way to do this, or is it possible to add native jest support? Thanks in advance!