Skip to content

Jest tests won't work without babel #2040

Closed
@Mourdraug

Description

@Mourdraug

Version

3.0.0-rc.10

Node and OS info

Node 10.7.0 / npm 6.3.0-next.0 / Windows 10

Steps to reproduce

  1. Create new project with only Jest plugin selected
  2. Run npm run test:unit

What is expected?

 PASS  tests/unit/HelloWorld.spec.js
  HelloWorld.vue
    √ renders props.msg when passed (22ms)

What is actually happening?

 FAIL  tests/unit/HelloWorld.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".
    Details:

    C:\node_workspace\test\tests\unit\HelloWorld.spec.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { shallowMount } from '@vue/test-utils';
                                                                                                ^

    SyntaxError: Unexpected token {

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

It works as expected if I install both Babel and Jest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs team reproWe acknowledged your report and will soon try to reproduce it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions