I have an image file I need to use in my tests. I need to pass this File
object around and call certain methods on it.
const readTestFile = () =>
new Promise((resolve, reject) => {
fs.readFile(testFilePath, (err, data) => {
if (err) return reject(err);
const blob = new File(data, "file.png"); // <-------- doesn't work in NodeJS
return resolve(blob);
});
});
How would I load it the "jest" way? Also I need a File
object (not a string), how would I get around this?
Fixed this by changing:
testEnvironment: "node"
to
testEnvironment: "jsdom"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.