Vue-cli: New installation running `test:unit` produces error

Created on 13 Sep 2018  ·  2Comments  ·  Source: vuejs/vue-cli

Version

3.0.2

Reproduction link

https://github.com/mikeerickson/vue-api-client/settings

Node and OS info

node 9.11.2, npm 6.4.0

Steps to reproduce

Clone Repo
Run npm install
Run npm run test:unit

What is expected?

Not sure where this goes haywire, but it works for a little while, then begins to fail (I am not touching the test)

What is actually happening?

Output

 FAIL  tests/unit/example.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:

    /Users/mikee/Documents/code/js/vue/vue-api-client/tests/unit/example.spec.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import "core-js/modules/es6.array.iterator";
                                                                                             ^^^^^^

    SyntaxError: Unexpected token import

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        4.779s
Ran all test suites.

Most helpful comment

Duplicate of #1879

You can try the following steps:

  1. Clear node_modules and remove package-lock.json, rerun npm install
  2. Clear Jest cache. You can find the cache location by running jest --showConfig. Look for cacheDirectory key. Its value is the name of the folder you'll need to remove.
  3. Rerun npm run test:unit

All 2 comments

Duplicate of #1879

You can try the following steps:

  1. Clear node_modules and remove package-lock.json, rerun npm install
  2. Clear Jest cache. You can find the cache location by running jest --showConfig. Look for cacheDirectory key. Its value is the name of the folder you'll need to remove.
  3. Rerun npm run test:unit

@sodatea ahhhhh snap, now I recall doing cache clear dance to fix this issue in the past. Thank you mucho

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GeertClaes picture GeertClaes  ·  31Comments

wuyuweixin picture wuyuweixin  ·  35Comments

yyx990803 picture yyx990803  ·  80Comments

lbicknese picture lbicknese  ·  41Comments

joeirimpan picture joeirimpan  ·  35Comments