You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm using mocha and ts-node to run some tests for a typescript project. It all worked perfectly until I tried to switch from popper to popper-lite. In short, I have a file doing this:
import { createPopper, Instance, Options } from '@popperjs/core/lib/popper-lite';
When I bundle the lib everything works, but when I run the test I have this error:
yarn run v1.22.11
$ env NODE_ENV=test mocha --config mocha.json 'test/**/*.ts?(x)'
/Users/matteo/dev/react-smart-select/node_modules/@popperjs/core/lib/popper-lite.js:1
import { popperGenerator, detectOverflow } from "./createPopper.js";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
etc...
If I understood correctly, this happens because popper's package.json doesn't have "type": "module" and because popper-lite.js doesn't have the .mjs extension...
I've tried every possible option combination inside tsconfig.json but nothing works. I even tried moduleTypes but it doesn't work either... what can I do? Thanks in advance for the help!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I'm using mocha and ts-node to run some tests for a typescript project. It all worked perfectly until I tried to switch from popper to popper-lite. In short, I have a file doing this:
When I bundle the lib everything works, but when I run the test I have this error:
If I understood correctly, this happens because popper's
package.json
doesn't have"type": "module"
and becausepopper-lite.js
doesn't have the.mjs
extension...I've tried every possible option combination inside
tsconfig.json
but nothing works. I even triedmoduleTypes
but it doesn't work either... what can I do? Thanks in advance for the help!here's my tsconfig.json:
here's mocha config:
Beta Was this translation helpful? Give feedback.
All reactions