mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
20 lines
627 B
JavaScript
20 lines
627 B
JavaScript
const Environment = require('jest-environment-jsdom');
|
|
|
|
/**
|
|
* A custom environment to set TextDecoder/TextEncoder
|
|
* Thanks https://stackoverflow.com/a/57713960/1976323
|
|
*/
|
|
module.exports = class CustomTestEnvironment extends Environment {
|
|
async setup() {
|
|
await super.setup();
|
|
if (typeof TextDecoder === 'undefined') {
|
|
const { TextDecoder } = require('util');
|
|
this.global.TextDecoder = TextDecoder;
|
|
}
|
|
if (typeof TextEncoder === 'undefined') {
|
|
const { TextEncoder } = require('util');
|
|
this.global.TextEncoder = TextEncoder;
|
|
}
|
|
}
|
|
};
|