Skip to content

When running jest its says Syntax Error: Unexpected Identifier #8679

Closed
@imskr

Description

@imskr

🐛 Bug Report

Test suite failed to run
({"Object.":function(module,exports,require,__dirname,__filename,global,jest){import $ from 'jquery';
Syntax Error: Unexpected Identifier

To Reproduce

In package.json:

"jest": {
        "setupFiles": ["./source/setup-jest.js"]
 },

In source/setup-jest.js

import $ from 'jquery';
global.$ = global.jQuery = $;

Expected behavior

It should pass the test run but it is showing syntax error

Run npx envinfo --preset jest

System:
OS: Linux 4.15 elementary OS 5.0 Juno
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 10.16.0 - /usr/local/bin/node
npm: 6.9.0 - /usr/local/bin/npm
npmPackages:
jest: ^24.8.0 => 24.8.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions