cloudacy / vue-markdown-render

A simple markdown parser for Vue using markdown-it.
MIT License
79 stars 10 forks source link

Compatibility with @vue/cli-plugin-unit-jest #4

Closed slaweet closed 3 months ago

slaweet commented 3 years ago

When I'm testing my component with https://cli.vuejs.org/core-plugins/unit-jest.html and my component contains import VueMarkdown from 'vue-markdown-render';, then the Jest test runner fails with:

● Test suite failed to run
--
44 |  
45 | /drone/src/node_modules/vue-markdown-render/dist/VueMarkdown.js:1
46 | ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Vue from "vue";
47 | ^^^^^^
48 |  
49 | SyntaxError: Cannot use import statement outside a module

I can resolve the error by mocking vue-markdown-render with

jest.mock('vue-markdown-render', () => (                                                             
  (fn: (...args: any[]) => void) => fn                                                               
));

But with all other 3-rd party modules, I don't have to do this.

p-kuen commented 3 years ago

Thanks for posting this issue. This is likely happening because of using ES modules for compiling TS. I will have a look at this soon.

p-kuen commented 3 months ago

This shouldn't be a problem anymore with the latest version of vue-markdown-render.