Skip to content
This repository has been archived by the owner on Aug 19, 2019. It is now read-only.

On fresh install, Jest Unit testing fails on ES6 #8

Open
onexdata opened this issue Nov 28, 2018 · 1 comment
Open

On fresh install, Jest Unit testing fails on ES6 #8

onexdata opened this issue Nov 28, 2018 · 1 comment

Comments

@onexdata
Copy link

FAIL test/jest/components/QBtn.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 more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html

Details:

C:\life.io\web-31\quasar-starter-ssr-pwa-jest-cypress\test\jest\components\QBtn.spec.js:6
import { mount, createLocalVue } from '@vue/test-utils';
^^^^^^

SyntaxError: Unexpected token import

  at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
@onexdata
Copy link
Author

Also tried the graphql-prisma and feathers branches, which have different setups for unit testing (i.e. they setup the env to be "test" instead of "dev", etc.

They both also fail on fresh install, first complaining that ./src/index.js doesn't exist, and they all fail.

Then when I add that file, Math.test.js passes, but everything else fails, saying import is an unexpected token (ES6).

I thought I tried this project a few months ago and this wasn't an issue... ?

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

No branches or pull requests

1 participant