mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-07-28 04:08:05 +00:00
fix TextEncoder/TextDecoder on CI
was working locally but not on CI for some reason
This commit is contained in:
committed by
David Lechner
parent
ba14910dae
commit
c3d4a07053
+6
-7
@@ -1,19 +1,18 @@
|
||||
const Environment = require('jest-environment-jsdom');
|
||||
const { TextEncoder, TextDecoder } = require('util')
|
||||
|
||||
/**
|
||||
* A custom environment to set TextDecoder/TextEncoder
|
||||
* 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 (typeof TextDecoder === 'undefined') {
|
||||
const { TextDecoder } = require('util');
|
||||
this.global.TextDecoder = TextDecoder;
|
||||
}
|
||||
if (typeof TextEncoder === 'undefined') {
|
||||
const { TextEncoder } = require('util');
|
||||
if (this.global.TextEncoder === undefined) {
|
||||
this.global.TextEncoder = TextEncoder;
|
||||
}
|
||||
if (this.global.TextDecoder === undefined) {
|
||||
this.global.TextDecoder = TextDecoder;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user