nothingismagick / quasar-starter-ssr-pwa-jest-cypress

Accelerated starter kit for building a quasar 17 app.
MIT License
47 stars 5 forks source link

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

Open onexdata opened 5 years ago

onexdata commented 5 years ago

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 commented 5 years ago

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... ?