Skip to content

v 8.0.2 won't work in jest tests while 7.0.1 did: Jest encountered an unexpected token #44

@erikrenberg

Description

@erikrenberg

In my create-react-app app (not Typescript) I use jest for tests. With 7.0.1 this works, but with 8.0.2 tests fail for components that use react-debounce-render.

Perhaps this is a jest configuration issue, but I still like to ask if react-debounce-render has been packaged/built/minified the right way in the npm package?

The reason I'm asking is the output from the test and the actual source in node_modules\react-debounce-render:

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
....

C:\dev\app\node_modules\react-debounce-render\dist\index.js:1
({"Object.":function(module,exports,require,__dirname,__filename,jest){import React, { Component } from 'react';
^^^^^^
SyntaxError: Cannot use import statement outside a module

I compared the old version's node_modules\react-debounce-render\lib\index.js and it is very different. It does not import React but starts like this:

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.debounce = void 0;

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions