mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
19 lines
580 B
JavaScript
19 lines
580 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;
|
|
}
|
|
}
|
|
};
|