postalsys / postal-mime

Email parser for browser and serverless environments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReferenceError: TextEncoder is not defined

binarykitchen opened this issue · comments

Only comes up when you import this for a React component and run this within a jest-dom test runner.

Known issue or is there a recipe for this?

What is the environment? TextEncoder is a built in global both in the latest versions of browsers and Node.

Sorry, sill me. Fixed with

// Polyfill for encoding which isn't present globally in jsdom
import { TextEncoder } from 'util'
global.TextEncoder = global.TextEncoder || TextEncoder

when setting up tests.