Closed as not planned
Description
Version
27.5.1
Steps to reproduce
- Clone my repo and bootstrap
git clone https://github.com/opensearch-project/OpenSearch-Dashboards.git
yarn osd bootstrap
- Create test file
jest_debug.test.ts
with simple test case
vi src/plugins/data_source/server/cryptography/jest_debug.test.ts
test('Debugging jest buffer behavior', () => {
expect(Buffer.from("test")).toBeInstanceOf(Uint8Array);
});
- Execute test file
jest_debug.test.ts
together with others
% yarn test:jest src/plugins/data_source/server/cryptography
yarn run v1.22.19
$ node scripts/jest src/plugins/data_source/server/cryptography
FAIL src/plugins/data_source/server/cryptography/jest_debug.test.ts
● Debugging jest buffer behavior
expect(received).toBeInstanceOf(expected)
Expected constructor: Uint8Array
Received constructor: Buffer
1 | test('Debugging jest buffer behavior', () => {
> 2 | expect(Buffer.from("test")).toBeInstanceOf(Uint8Array);
| ^
3 | });
4 |
at Object.<anonymous> (src/plugins/data_source/server/cryptography/jest_debug.test.ts:2:33)```
- Execute test file
jest_debug.test.ts
only
% yarn test:jest src/plugins/data_source/server/cryptography/jest_debug.test.ts
yarn run v1.22.19
$ node scripts/jest src/plugins/data_source/server/cryptography/jest_debug.test.ts
PASS src/plugins/data_source/server/cryptography/jest_debug.test.ts
✓ Debugging jest buffer behavior (3 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.727 s, estimated 2 s
Ran all test suites matching /src\/plugins\/data_source\/server\/cryptography\/jest_debug.test.ts/i.
✨ Done in 5.56s.
Expected behavior
#4422 (comment) This solution should work both single test suite on single node process, but multiple test suites with child processes.
Actual behavior
The global config mentioned #4422 (comment) doesn't apply to child processes when there are multiple test suites. Very appreciated anyone helps me out.
Additional context
- Closed Jest repo issue Jest breaks Buffer instanceof Uint8Array #4422
- Created issue from OSD repo [Test] local unit tests failed opensearch-project/OpenSearch-Dashboards#2459
- Known issue from AWS Encryption SDK JavaScript instanceOf and different versions of the underlying Encryption SDK modules. aws/aws-encryption-sdk-javascript#126
- Jest config from OSD repo in
src/dev/jest/config.js
globals: {
Uint8Array: Uint8Array,
},
Environment
System:
OS: macOS 12.6
CPU: 2.6 GHz 6-Core Intel Core i7
Binaries:
Node: 14.20.0 - ~/.nvm/versions/node/v14.20.0/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.14.17 - ~/.nvm/versions/node/v14.20.0/bin/npm
npmPackages:
jest: ^27.5.1
"@types/jest": "^27.4.0",
"babel-jest": "^27.5.1",