[Vuejs]-Jest : How to mock vue-router used in vuex

0👍

This error is related to the fact that Jest runs in a Node.js environment, and you are using export default, which does not work by default in Node.js (Node uses module.exports). I guess you are using webpack for your dev/production build, but not for the test environment.

Are you using Jest? If so, you will need to set up babel-jest so Jest knows how to read ES Modules syntax (import/export).

Read more here: https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-jest

This can be annoying to set up, let me know if you need more help to get it working.

Leave a comment