excellentingenuity / laravel-mix-vue-svgicon

Laravel Mix extension that provides loading svgs as a vue component named icon, compatible with Adam Wathan's Blade extension.
MIT License
20 stars 3 forks source link

Using the package with testing suite like jest #8

Open nirajfu3e opened 2 years ago

nirajfu3e commented 2 years ago

Thanks for the package as it has been very useful.

I am having an issue where using this package seems to break the jest test with errors like:

 Error: Cannot find module 'SVGPATH/foo.svg' from 'Icon.vue'

I am using the SVGPath in a vue component as follows:

// Icon.vue

getIcon(icon) {
  return require(`SVGPATH/${icon}.svg`);
}

Tried adding the following to jest.setup.js but no luck:

const mix = require('laravel-mix');
require('laravel-mix-vue-svgicon');

Is there any way we can get this working with the test suite? Thanks.