From 201236195d3c5c0108c764bc56734d418a687e76 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 22 Sep 2021 22:31:58 +0200 Subject: [PATCH] test(cloudflare): provide TextEncoder and TextDecoder jsdom/jsdom#2524 --- test/presets/cloudflare.test.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/presets/cloudflare.test.mjs b/test/presets/cloudflare.test.mjs index 144bec28db..472c0c0d00 100644 --- a/test/presets/cloudflare.test.mjs +++ b/test/presets/cloudflare.test.mjs @@ -1,5 +1,6 @@ import { resolve } from 'path' import { promises as fsp } from 'fs' +import { TextEncoder, TextDecoder } from 'util' import { JSDOM } from 'jsdom' import { setupTest, testNitroBehavior } from './_tests.mjs' @@ -42,12 +43,18 @@ describe('nitro:preset:cloudflare', () => { } } - + `, { runScripts: 'dangerously' } ) + // https://github.com/jsdom/jsdom/issues/2524 + // https://github.com/inrupt/solid-client-authn-js/issues/1676#issuecomment-917016646 + dom.window.TextEncoder = TextEncoder + dom.window.TextDecoder = TextDecoder + dom.window._load() + return async ({ url, headers, method, body }) => { const data = await dom.window.handleEvent({ request: {