Answer the question
In order to leave comments, you need to log in
When trying to find a file when running tests for karma and jasmine, it says fs.readFile is not a function, why is that?
Good afternoon, you need to write a function that takes a zip archive as a parameter, as well as write tests for karma and jasmine. The problem is that when I run tests and I want my file search function (it is needed only for tests) to find my test file and after passing it to my function in which I will work with this file, it falls.
Test file code:
const fs = require('fs');
const JSZip = require("jszip");
const searchfile = () => {
fs.readFile('./data/2-11253540.zip', function (err, data) {
if (err) throw err;
JSZip.loadAsync(data).then(function (zip) {
console.log('Process Zip: ', zip);
});
});
};
describe('Process', () => {
const process = require('./process');
searchfile();
it('001', () => expect(process()).toEqual(null));
});
Answer the question
In order to leave comments, you need to log in
Your browser does not have the fs module as it is only found in the node.js environment.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question