From c843d1b7bda6d29a56456f82b6f5517b47631ef6 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 5 Jul 2022 14:52:00 -0400 Subject: [PATCH] Fix error with jose package upgrade Signed-off-by: Sebastian Malton --- src/jest-28-resolver.js | 9 ++++++--- src/jest.setup.ts | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/jest-28-resolver.js b/src/jest-28-resolver.js index 46a94a5288..9ee76fd788 100644 --- a/src/jest-28-resolver.js +++ b/src/jest-28-resolver.js @@ -21,9 +21,12 @@ module.exports = (path, options) => { // Once we're able to migrate our Jest config to ESM and a browser crypto // implementation is available for the browser+ESM version of uuid to use (eg, via // https://github.com/jsdom/jsdom/pull/3352 or a similar polyfill), this can go away. - if (pkg.name === "uuid") { - delete pkg["exports"]; - delete pkg["module"]; + switch (pkg.name) { + case "uuid": + case "jose": + delete pkg["exports"]; + delete pkg["module"]; + break; } return pkg; diff --git a/src/jest.setup.ts b/src/jest.setup.ts index 2ab9b1b52d..6e7ef2fc85 100644 --- a/src/jest.setup.ts +++ b/src/jest.setup.ts @@ -7,6 +7,7 @@ import fetchMock from "jest-fetch-mock"; import configurePackages from "./common/configure-packages"; import { configure } from "mobx"; import { setImmediate } from "timers"; +import { TextEncoder, TextDecoder as TextDecoderNode } from "util"; // setup default configuration for external npm-packages configurePackages(); @@ -32,3 +33,6 @@ global.fail = ((error = "Test failed without explicit error") => { process.on("unhandledRejection", (err: any) => { global.fail(err); }); + +global.TextEncoder = TextEncoder; +global.TextDecoder = TextDecoderNode as unknown as typeof TextDecoder;