Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token import - ESM in dist files #43

Closed
frandiox opened this issue Jul 22, 2018 · 4 comments
Closed

Unexpected token import - ESM in dist files #43

frandiox opened this issue Jul 22, 2018 · 4 comments

Comments

@frandiox
Copy link
Contributor

Hi! Some distribution files contain ES modules: https://unpkg.com/vue-cli-plugin-apollo@0.15.0/graphql-client/dist/index.js

Is this intended? It breaks Jest since it doesn't transpile node_modules by default.

As a workaround, renaming .babelrc to .babel.config.js and using transformIgnorePatterns in Jest's config make it work again. More details here.

Thanks!

@frandiox frandiox changed the title Unexpected token import Unexpected token import - ESM in dist files Jul 22, 2018
@Akryum
Copy link
Owner

Akryum commented Jul 22, 2018

Why do you need it in Unit tests?

@frandiox
Copy link
Contributor Author

My LoginView imports onLogin and onLogout from vue-apollo.js. That file, at the same time, imports stuff from vue-cli-plugin-apollo: https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/generator/templates/vue-apollo/default/src/vue-apollo.js#L3

@Akryum
Copy link
Owner

Akryum commented Jul 22, 2018

Then you should mock those. https://jestjs.io/docs/en/manual-mocks

@frandiox
Copy link
Contributor Author

Thanks for the prompt answer. I assume you mean this is intended then 👍

For now, I think I prefer adding transformIgnorePatterns instead of mocking every test related to Apollo. Perhaps this could be useful for somebody else.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants