mirror of https://github.com/waku-org/js-waku.git
Fix TextDecoder error in tests
This commit is contained in:
parent
7d9f8c03c1
commit
f0fe7dce02
|
@ -2,7 +2,6 @@
|
|||
.nyc_output
|
||||
build
|
||||
node_modules
|
||||
test
|
||||
src/**.js
|
||||
coverage
|
||||
*.log
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"test": "react-scripts test --env=./test/custom-test-env.js",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
const Environment = require('jest-environment-jsdom');
|
||||
|
||||
module.exports = class CustomTestEnvironment extends Environment {
|
||||
async setup() {
|
||||
await super.setup();
|
||||
if (typeof this.global.TextEncoder === 'undefined') {
|
||||
const { TextEncoder, TextDecoder } = require('util');
|
||||
this.global.TextEncoder = TextEncoder;
|
||||
this.global.TextDecoder = TextDecoder;
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue