Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 8085784

Browse files
committed
fixes test RUNNER, even though the tests still fail
1 parent 3a6940e commit 8085784

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

jestEnv.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Environment = require('jest-environment-jsdom')
2+
3+
/**
4+
* A custom environment to set the TextEncoder that is required by TensorFlow.js.
5+
*/
6+
module.exports = class CustomTestEnvironment extends Environment {
7+
async setup () {
8+
await super.setup()
9+
if (typeof this.global.TextDecoder === 'undefined') {
10+
const { TextDecoder } = require('util')
11+
this.global.TextDecoder = TextDecoder
12+
}
13+
if (typeof this.global.TextEncoder === 'undefined') {
14+
const { TextEncoder } = require('util')
15+
this.global.TextEncoder = TextEncoder
16+
}
17+
}
18+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"start": "react-scripts start",
88
"build": "react-scripts build",
9-
"test": "react-scripts test",
9+
"test": "react-scripts test --env=./jestEnv.js",
1010
"eject": "react-scripts eject"
1111
},
1212
"author": "",

0 commit comments

Comments
 (0)