How to mock a middleware in supertest?
问题 I want to test if the middleware in app.js is called. Although I mock the module work.js , it still runs the original code. app.js const work = require('./work') const express = require('require') const app = express() .use(work) .use(...) .get(...) module.exports = app work.js function work(req, res, next){...} module.exports = work app-test.js const supertest = require('supertest') const app = require('../app') test('test middleware in app.js', async(done) => { jest.mock('../work', () =>