testing-library / react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.
https://testing-library.com/react
MIT License
18.97k stars 1.1k forks source link

Module parse failed: Unexpected token for the act-compat.js #1298

Closed YevheniiaChursina closed 5 months ago

YevheniiaChursina commented 5 months ago

What you did:

Updating to version 14.3.0 and above causes the error

What happened:

ERR! /vercel/path0/node_modules/@testing-library/react/dist/act-compat.js 13:28
ERR! Module parse failed: Unexpected token (13:28)
ERR! You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
ERR! | function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
ERR! | function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
ERR! > const reactAct = React.act ?? DeprecatedReactTestUtils.act;
ERR! | function getGlobalThis() {
ERR! |   /* istanbul ignore else */
ERR!  @ /vercel/path0/node_modules/@testing-library/react/dist/pure.js 58:41-64
ERR!  @ /vercel/path0/node_modules/@testing-library/react/pure.js

Problem description:

Updating @testing-library/react to version 14.3.0 and above causes the error and fails the storybook build

eps1lon commented 5 months ago

Fixed in https://github.com/testing-library/react-testing-library/releases/tag/v15.0.1 and https://github.com/testing-library/react-testing-library/releases/tag/v14.3.1