Jest test failing
Issue description
- components:
any - reactstrap version
#5.0.0-beta.2 - import method
es(typescript)(if umd, are you using the "full" version (only for v5+)?) - react version
#16.2.0
What is happening?
Any Jest test in app created by create-react-app fail to run.
Steps to reproduce issue
- create-react-app my-app --scripts-version=react-scripts-ts
- npm install --save [email protected] @types/reactstrap
- import and use any reactstrap component to App.ts, for ex. Container
- npm run test
Error message in console
● Test suite failed to run
C:\temp\my-app\node_modules\react-popper\lib\react-popper.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export { default as Manager } from './Manager';
^^^^^^
SyntaxError: Unexpected token export
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at Object.<anonymous> (node_modules/reactstrap/dist/reactstrap.cjs.js:14:19)
at Object.<anonymous> (src/App.tsx:15:20)
I don't think the reason is typescript.
As I understood, Jest runs as node process, and create-react-app setup jest to not transpile any files under node_modules folder. Since react-popper/package.json conains "main": "lib/react-popper.js", and version under /lib contains es6' export statements, node finally gets those export statements and fails. If I change react-popper/package.json to point main to dist: "main": "dist/react-popper.js", tests pass.
I can only confirm I have the very same issue. My app is created using create-react-apps
src/App/App.test.js
● Test suite failed to run
/Users/venelin/projects/stylbum-web-v2/node_modules/react-popper/lib/react-popper.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export { default as Manager } from './Manager';
^^^^^^
SyntaxError: Unexpected token export
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at Object.<anonymous> (node_modules/reactstrap/dist/reactstrap.cjs.js:14:19)
I am also seeing the same issue.
So do I( I think it is react-popper issue.
Quick fix - revert to "reactstrap": "5.0.0-beta". It has older react-popper version.
Same issue
same cause, but made my react projects cannot run in node.js for server rendering
i saw once that #835 has upgraded the react-popper to ^0.8.2, in which the release of the [email protected] has correctly transformed babel-fied JSX code in lib/, but for some reason the ^0.8.2 description in package.json is being rewritten back as 0.8.1
https://github.com/reactstrap/reactstrap/commit/b515e6bbb137443550f9ea7b0b2ba48113ebd169
reverted the updated react-popper down to 0.8.1. That commit claims to fix the broken build, so I'm not sure what is going on as it does the opposite for me.
Same issue here. Reverted my reactstrap version to 5.0.0-beta and it is resolved. Thanks @sinxwal
Same here, any news?
The PR in react-popper has been merged, just waiting on it to be published in a release.