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,
```js
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):
```js
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',
}))
}
Original comment:
This seems to be fixed with https://github.com/mochajs/mocha/pull/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.