-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with es6 modules #63
Comments
I'm pretty sure this is an issue with jest in general. You might find some useful information at jestjs/jest#6229 or jestjs/jest#2081 I know I've encountered similar issues before, but I can't remember exactly what the issue was or how I solved it. Sorry I can't be of more help, but if you do figure it out, please add a comment of it here so we get a record of how to fix it. |
I hit this and took awhile to sort it out. The solution presented by @jchavarri presented here (https://reasonml.chat/t/bs-jest-or-vanilla-jest/1608/13) is what helped. There's a demo repo here: (https://github.com/jchavarri/example-bsb-jest-es6) The key parts are the
You may want to mention this in the |
And, actually, I encountered a some issues with that setup. The one in
|
@ijcd so you ended up using the latter setup? I've been having to use commonjs in order to have everything working fine. I'm thinking about trying out your approach. Although seems like you are still finding easter eggs
|
Sure. I'm definitely open for a PR! |
@vasco3 Yes, I'm using the second setup now. I'm not sure what the issue with the first one was, but the second seems more direct and obvious. The first is trying to avoid depending on babel (I think) but my project is using it anyway. |
This worked for me. npm install --save-dev babel-plugin-transform-es2015-modules-commonjs // babel.config.js
module.exports = {
env: {
test: {
plugins: ["transform-es2015-modules-commonjs"],
},
},
}; // package.json
"jest": {
"transformIgnorePatterns": [
"/node_modules/(?!@glennsl/bs-jest|bs-platform|@rescript).+\\.js$"
]
} |
Now I only test functions in files that don't contain React components. That stopped the import bug from showing up. |
Just want to note that this still works but for the latest version of
|
So far, I am having good luck with using the jest instructions for enabling esm in node, combined with setting appropriate babel jest settings in jest config. I will return and document the details once the dust has settled. |
Hi!
I have small problem with bs-jest.
In my
bsconfig.json
I have es6 modules:When I run tests, it gives me the error like below:
When I change
module
tocommonjs
, everything starts working. (I can't do this permamently, because I have own bindings, that not compatible withcommonjs
)The text was updated successfully, but these errors were encountered: