Skip to content

[Bug]: jest-environment-jsdom webIDL validator issue in node 18 #14379

Closed as not planned
@MGibson1

Description

@MGibson1

Version

29.6.2

Steps to reproduce

  1. Clone my repo at https://github.com/mgibson1/jest-jsdom-issue
  2. Install with npm ci
  3. Test with npm run test
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions