-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
BigInt support #6829
Comments
I can confirm the 123n syntax is broken on Jest 23.5.0 and Node 10.8.0, with default configuration. |
It's not a bug, it's lack of functionality... Happy to accept PR supporting BigInt properly. But actually, shouldn't this have its own matcher? |
I understand the matchers would have to be updated for BigInt support, they're semantically different from Numbers. From a syntax perspective, I don't understand why this isn't working, as the |
Syntax error is babel I think, you need the syntax plugin (not the transform) or disable babel-jest in your project |
I tried this on a fresh install of Jest, and it happened with and without babel-jest. |
Also see babel/babel#7660 |
Thanks, I didn't realize Babel was loaded by default. I think it would be less surprising if it didn't so Jest behaves like the current Node version as closely as possible. Or perhaps there could be different defaults in the node (off) and jsdom (on) environments. |
It's part of the zero config experience, I don't think we want to change that. And I don't think the test environment should mess with the config oif the project, that'd be super confusing. We could possibly add a cleaner error. We've added one when node gets a syntax error (#6275), but we could also print some helpful text if we get a syntax error from Babel ("This is a syntax error from babel, which normally menas that you're missing a syntax plugin, even though the underlying version of node might support your syntax. blablabla Jest always uses babel for mocking and code coverage, blablabla"). Something like that? |
If we're going to bundle Babel anyway, could we enable all syntax plugins? Or at least whatever's in babel-preset-env? |
Again, see babel/babel#7660 |
I understand this is hoping to get fixed upstream in babel/babel#7660, but I think an error message like @SimenB mentioned above would be helpful. I can try to poke around and submit a PR. I was testing a pure Node 10 project using async iterators. I was super confused when Jest couldn't run tests but Mocha had no problems until I found this issue, and the fix. |
+1 on a better error message if you want to submit the PR @MattMorgis |
There is a problem with BigInt but it seems to disappear when "actual" property is removed from object returned by a custom matcher. const {diff} = require('jest-diff');
}, |
🐛 Bug Report
BigInt was introduced in Node.js v10.4.0. This feature is expected to be supported by jest.
An script to test is added in this issue.
Currently the situation is:
BigInt(x) can be used inside Jest but is only supported by the toBeEqual function, but not by toBeGreaterThan, toBeGreaterThanOrEqual, toBeLessThan or toBeLessThanOrEqual.
The format 123n is not supported and causes an error without executing the tests:
To Reproduce
Use this script. As the format 123n is not supported and break the execution, you can comment the second test to check the other behaviours.
Expected behavior
Link to repl or repo (highly encouraged)
Script is already added to the issue
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: