Skip to content Skip to sidebar Skip to footer

How To Mock Fs.readfilesync With Jest

in my app.js I have this function: const bodyParser = require('body-parser') const express = require('express') const app = express() const cors = require('cors') app.use(bodyParse

Solution 1:

Mocking modules requires calling mock('modulename') like this:

jest.mock('fs');

See Mocking modules and Manual module mocks

Post a Comment for "How To Mock Fs.readfilesync With Jest"