Files
pybricks-code/test-env.js
T
David Lechner 90817a1ae7 github: add CI for pull requests
and hacks to get tests working
2020-05-20 14:52:45 -05:00

16 lines
455 B
JavaScript

const Environment = require('jest-environment-jsdom');
/**
* A custom environment to set the TextEncoder
* Thanks https://stackoverflow.com/a/57713960/1976323
*/
module.exports = class CustomTestEnvironment extends Environment {
async setup() {
await super.setup();
if (typeof TextEncoder === 'undefined') {
const { TextEncoder } = require('util');
this.global.TextEncoder = TextEncoder;
}
}
};