Skip to content
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 (mocha v8.3+) #202

Closed
chharvey opened this issue Feb 17, 2021 · 0 comments
Closed

BigInt support (mocha v8.3+) #202

chharvey opened this issue Feb 17, 2021 · 0 comments

Comments

@chharvey
Copy link

chharvey commented Feb 17, 2021

Original comment:

I’m getting this issue with Node.js’s built-in assert.strictEqual function only when using with Mocha.

When running Node (v14.15.0) on the command line,

assert.strictEqual(0n, 1n);

I get the error:

Uncaught AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

0n !== 1n

This is as expected, as the error reports what it should report.

But when running in Mocha (with gulp and ts-node):

import * as assert from 'assert'; // Node.js

describe('module', () => {
   it('test', () => {
      assert.strictEqual(0n, 1n);
   });
});

TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at processImmediate (internal/timers.js:461:21)

Any idea why assert.strictEqual runs differently in Mocha than in the Node.js REPL?

Configurations: (click to expand) Gulp file:
function test() {
	return gulp.src('./test/**/*.ts')
		.pipe(mocha({
			require: 'ts-node/register',
		}))
}
NPM dependencies:
  "devDependencies": {
    "@types/mocha": "^8.0.0",
    "@types/node": "^14.0.1",
    "gulp": "^4.0.2",
    "gulp-mocha": "^7.0.2",
    "gulp-typescript": "^5.0.1",
    "ts-node": "^9.0.0",
    "typescript": "~4.0.3"
  },

This seems to be fixed with mochajs/mocha#4112, but that is in mocha v8.3.0, and this project only uses version ^6. I tried submitting a PR to retroactively apply the fix to v6, but they denied saying that LTS is not pursued.

One possible solution to this issue would be to upgrade to mocha ^8.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant