🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@bufbuild/jest-environment-jsdom

Package Overview
Dependencies
Maintainers
10
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bufbuild/jest-environment-jsdom

A modern jsdom test environment for Jest

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
10
Created
Source

@bufbuild/jest-environment-jsdom

An extension of jest-environment-jsdom with support for the Encoding API.

Background

When using the test framework Jest for a web application, you will likely use the "jsdom" test environment to make the DOM available in tests. But if your code or one of your dependencies relies on the encoding API, you will see the following error when running tests:

ReferenceError: TextEncoder is not defined

This package adds the Node.js built-in classes TextEncoder and TextDecoder to the jsdom test environment to work around the problem. If you can spare the time, consider helping out with the upstream issue in the jsdom project.

Usage

Install the package (note that jest-environment-jsdom is still required as a peer dependency):

npm install --save-dev jest-environment-jsdom @bufbuild/jest-environment-jsdom

Update the testEnvironment property of your Jest config like so:

import type { Config } from 'jest';

const config: Config = {
- testEnvironment: 'jsdom',
+ testEnvironment: '@bufbuild/jest-environment-jsdom',
...
};

FAQs

Package last updated on 15 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts