greenpress / vuex-composition-helpers

A util package to use Vuex with Composition API easily.
https://www.npmjs.com/package/vuex-composition-helpers
MIT License
288 stars 32 forks source link

Error when running jest with components that import this package #42

Closed devTeaa closed 2 years ago

devTeaa commented 3 years ago

Hi, I've problems when jest trying to run unit test that uses this package, I've read that we need to manually transpile this? But I'm not using typescript, is there an example for me to use? My stack isn't on vue-cli so I have my own webpack/loader etc. Also it would be nice if the default is transpiled instead of us figuring out how to transpile this ourselves for our project.

PS. I have added transformIgnorePatterns on jest.config.js, after that I'm a bit lost

davidmeirlevy commented 3 years ago

You can use the files at "vue-composition-helpers/dist"

It have the same functions, but compiled.

The fact you can compile yourself can help you to tree-shake only the things you use, and the ability to work with vue-cli, vite, nuxt build, as native es-modules, or customized webpack config.

devTeaa commented 3 years ago

I did import from vuex-composition-helpers/dist but it still shows some transpiling error like "$export is not a function" from jest

khangvo88 commented 2 years ago

I resolved it by put

transformIgnorePatterns: [
    "/node_modules/(?!vuex-composition-helpers).+\\.js$",
  ],

into jest.config.js