niksmr / vue-masked-input

Masked input component for Vue.js
https://niksmr.github.io/vue-masked-input/
MIT License
454 stars 93 forks source link

SyntaxError: Unexpected token import when using in Jest tests #52

Open artemv opened 6 years ago

artemv commented 6 years ago

If vue-masked-input is used inside a component tested by Jest I get following error:

 FAIL  test/unit/specs/PhoneEntry.spec.js
  ● Test suite failed to run

    /Users/artem/my-project/node_modules/vue-masked-input/dist/maskedInput.js:3
    import InputMask from 'inputmask-core';
    ^^^^^^

    SyntaxError: Unexpected token import

This happens because dist/maskedInput.js bundle is using import constructs shamelessly - this should be eliminated by Babel. Some Webpack envs handle this, some not, but Jest never.