Closed robotichead closed 3 years ago
There is currently a work around. We will need to use the jest.mock feature to mock out each icon that we use with a blank return.
jest.mock('@iconify-icons/mdi-light/home.js', () => jest.fn());
babel-jest
is not applied to node_modules by default, and Jest does not read ES modules out of the box. This is actually a jest issue, not really test utils. see here.
You could configure Jest to apply es modules transforms to @iconify-icons
. Alternatively, @iconify-icons
might want to consider shipping a commonjs module (unlikely this happens, though). So you probably want to just tell jest not to ignore that node_module.
Here is a similar issue with a worked example: https://github.com/vuejs/vue-test-utils-next/issues/280#issuecomment-750176994
See this file for an example config: https://github.com/HomyeeKing/learn-test/pull/1/files#diff-1e058ca1442e46581b13571fb8d261f9e1f5657e26c96634d4c1072f0f0347f1 (you will need to tweak it for your use-case).
I am sure this is not a problem in vue-jest, but a general jest config issue. If you'd like to add a note in the README, that'd be great!
Thank you for your reply. I will close this ticket as we both think this is actually a Jest config issue.
Git Source replicating the issue - https://github.com/robotichead/unworking-vue-jest
Stream of issue - https://www.twitch.tv/videos/952503490
Description of issue
When including the line
import homeIcon from '@iconify-icons/mdi-light/home';
in the VueJS component, I will receive the errorPackage.json file
The package.json file contains all my configuration, and has essentially been copied and pasted code from the documents.
Vue Component
Method
git clone git@github.com:robotichead/unworking-vue-jest.git
cd ./unworking-vue-jest
npm install
npm run test