IssueRaiser

Jest tests can't process import statement

### Version 3.0.0-rc.2 ### Reproduction link [https://github.com/ijdickinson/vue-cli-jest-problem](https://github.com/ijdickinson/vue-cli-jest-problem) ### Steps to reproduce This is a similar problem to [1475](https://github.com/vuejs/vue-cli/issues/1475), but I can't find a way to resolve it. I created a new app with vue-cli, selecting Jest tests. I added a simple POJO (`src/models/model.js`) and a test for it (`tests/model.spec.js`). To repro the problem, just `npm run test:unit` ### What is expected? Tests to pass, or at least run ### What is actually happening? $ npm run test:unit > test-application@0.1.0 test:unit /home/ian/workspace/project/test-application > vue-cli-service test:unit FAIL tests/unit/model.spec.js ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". Here's what you can do: • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config. • If you need a custom transformation specify a "transform" option in your config. • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option. You'll find mo

Posted by ijdickinson on Jun 15, 2018, 4:00 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

reliability (SaaS)

Jest tests can't process import statement

ijdickinsonJun 15, 2018, 4:00 PM

### Version 3.0.0-rc.2 ### Reproduction link [https://github.com/ijdickinson/vue-cli-jest-problem](https://github.com/ijdickinson/vue-cli-jest-problem) ### Steps to reproduce This is a similar problem to [1475](https://github.com/vuejs/vue-cli/issues/1475), but I can't find a way to resolve it. I created a new app with vue-cli, selecting Jest tests. I added a simple POJO (`src/models/model.js`) and a test for it (`tests/model.spec.js`). To repro the problem, just `npm run test:unit` ### What is expected? Tests to pass, or at least run ### What is actually happening? $ npm run test:unit > test-application@0.1.0 test:unit /home/ian/workspace/project/test-application > vue-cli-service test:unit FAIL tests/unit/model.spec.js ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". Here's what you can do: • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config. • If you need a custom transformation specify a "transform" option in your config. • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option. You'll find mo

Comments (0)

No comments yet. Start the discussion.

Comment on this issue