Files
pybricks-code/test/env.js
T
David Lechner 71ad9c1b1b Update to create-react-app 4
- had to update eslint deps
- ran into https://github.com/palantir/blueprint/issues/4112
- had to move beta.svg out of static/
- had to fix prettier formatting changes
- ran into https://github.com/facebook/jest/issues/7780
2020-11-20 21:08:53 -06:00

23 lines
741 B
JavaScript

const Environment = require('jest-environment-jsdom');
const { TextEncoder, TextDecoder } = require('util')
/**
* A custom environment to set TextEncoder/TextDecoder
* Thanks https://stackoverflow.com/a/57713960/1976323
*/
module.exports = class CustomTestEnvironment extends Environment {
async setup() {
await super.setup();
if (this.global.TextEncoder === undefined) {
this.global.TextEncoder = TextEncoder;
}
if (this.global.TextDecoder === undefined) {
this.global.TextDecoder = TextDecoder;
}
// work around https://github.com/facebook/jest/issues/7780
this.global.Uint8Array = Uint8Array;
this.global.ArrayBuffer = ArrayBuffer;
}
};