Version
27.3.1
Steps to reproduce
Clone MatrixAI/TypeScript-Demo-Lib#38. Run nix-shell to enter into the development environment.
Go to src/native/index.cpp.
NAPI_METHOD(createArr) {
// Create arr with length of 1
napi_value arr;
NAPI_STATUS_THROWS(napi_create_array_with_length(env, 1, &arr))
// Set the value on the arr
napi_value value;
NAPI_STATUS_THROWS(napi_create_double(env, 0.5, &value));
NAPI_STATUS_THROWS(napi_set_element(env, arr, 0, value))
return arr;
}
This native function just creates an JS array, and sets 5 to it. Basically [5].
Now in jest, go to tests/native.test.ts.
Test this:
expect(native.createArr()).toEqual([0.5]);
Expected behavior
I would expect [0.5] to be [0.5].
Actual behavior
It says: Received: serializes to the same string.
In fact, you can test it like:
const arr = native.createArr();
expect(arr[0]).toStrictEqual(0.5);
And this does work.
Additional context
No response
Environment
System:
OS: Linux 5.10 Matrix ML 1
CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
Binaries:
Node: 16.14.2 - /nix/store/zl4bvsqfxyx5vn9bbhnrmbmpfvzqj4gd-nodejs-16.14.2/bin/node
npm: 8.5.0 - /nix/store/zl4bvsqfxyx5vn9bbhnrmbmpfvzqj4gd-nodejs-16.14.2/bin/npm
npmPackages:
jest: ^27.2.5 => 27.3.1
Version
27.3.1
Steps to reproduce
Clone MatrixAI/TypeScript-Demo-Lib#38. Run
nix-shellto enter into the development environment.Go to
src/native/index.cpp.This native function just creates an JS array, and sets
5to it. Basically[5].Now in
jest, go totests/native.test.ts.Test this:
Expected behavior
I would expect
[0.5]to be[0.5].Actual behavior
It says:
Received: serializes to the same string.In fact, you can test it like:
And this does work.
Additional context
No response
Environment
System: OS: Linux 5.10 Matrix ML 1 CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor Binaries: Node: 16.14.2 - /nix/store/zl4bvsqfxyx5vn9bbhnrmbmpfvzqj4gd-nodejs-16.14.2/bin/node npm: 8.5.0 - /nix/store/zl4bvsqfxyx5vn9bbhnrmbmpfvzqj4gd-nodejs-16.14.2/bin/npm npmPackages: jest: ^27.2.5 => 27.3.1