Skip to content

Commit 21f0b6e

Browse files
Polyfill TextEncoder/TextDecoder for ReactDOM
1 parent 2312168 commit 21f0b6e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/setupTests.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1+
import { TextDecoder, TextEncoder } from 'util';
12
import '@testing-library/jest-dom';
23
import { outdent } from 'outdent';
34

5+
/**
6+
* Polyfill TextEncoder/TextDecoder for ReactDOM
7+
*
8+
* @see {@link https://github.com/jsdom/jsdom/issues/1695}
9+
*/
10+
Object.defineProperties(window, {
11+
TextEncoder: {
12+
value: TextEncoder,
13+
configurable: true,
14+
enumerable: false,
15+
writable: true,
16+
},
17+
TextDecoder: {
18+
value: TextDecoder,
19+
configurable: true,
20+
enumerable: false,
21+
writable: true,
22+
},
23+
});
24+
425
/**
526
* Polyfill Element methods for NHS.UK frontend error summary
627
*

0 commit comments

Comments
 (0)