Description
Version
29.6.2
Steps to reproduce
- Clone my repo at https://github.com/mgibson1/jest-jsdom-issue
- Install with
npm ci
- Test with
npm run test
- Observe type error (note, the type of the 2nd argument is
ArrayBuffer
:
TypeError: Failed to execute 'importKey' on 'SubtleCrypto': 2nd argument is not instance of ArrayBuffer, Buffer, TypedArray, or DataView.
Expected behavior
Tests should pass since parameter types match
Actual behavior
Test fails with TypeError
Additional context
Working with JSDOM
The testEnvironment-node
branch changes test environment to node and injects a simple JSDOM into global.
Tests pass in this branch.
Working when using a TypedArray
the typed-array
branch still uses jsdom as a test environment, but converts usage in crypto from ArrayBuffer
to TypedArray
. I don't see why these types would be interpreted differently by the validator, but it appears that this is a reasonable workaround.
Suggested JSDOM workaround for other v22 issues
It was suggested to override JSDOM to use the correct version for other improvements that haven't made their way in to jest-environment-jsdom
yet, but I'd pegged the package to the current release and this issue persists. It must be due to some configuration happening in jest-environment-jsdom
.
Environment
System:
OS: macOS 13.4.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 18.17.0 - /usr/local/bin/node
npm: 9.6.7 - /usr/local/bin/npm