-
-
Notifications
You must be signed in to change notification settings - Fork 538
Closed
Labels
Description
When importing Tooltip, Jest throws the following error unless you specifically import the cjs version.
react-tooltip v5.2.0
To reproduce, in a project running Node 18, React 18, and Jest 29, import tooltip:
import { Tooltip as ReactTooltip, ITooltip } from 'react-tooltip';
Project runs fine, but jest tests fail.
When running jest tests I see the following error:
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.
...node_modules/react-tooltip/dist/react-tooltip.esm.min.js:1
So, it's possible it's just my jest configuration that is unable to support this syntax, but the tests run fine with standard imports from other react ui packages.
Current solution: directly import from the dist directory's .cjs version.
import { Tooltip as ReactTooltip, ITooltip } from '../../node_modules/react-tooltip/dist/react-tooltip.cjs';
MitchelSt, mmta and KholdStare