Javascript 如何使用模拟请求/响应对象测试express应用程序
下面的代码不起作用。我使用了Javascript 如何使用模拟请求/响应对象测试express应用程序,javascript,express,testing,Javascript,Express,Testing,下面的代码不起作用。我使用了节点模拟http。我只是想避免使用supertest,而是创建一个模拟的http.IncomingMessagehttp.ServerResponse对象 describe('Jest setup', () => { test('Get all accounts', async () => { const request = createRequest({ method: 'GET', url: '/api/accoun
节点模拟http
。我只是想避免使用supertest
,而是创建一个模拟的http.IncomingMessage
http.ServerResponse对象
describe('Jest setup', () => {
test('Get all accounts', async () => {
const request = createRequest({
method: 'GET',
url: '/api/accounts',
});
const response = createResponse();
await app(request, response);
console.log(response._getData());
});
});