1
Sinon documentation说,它是可能的访问请求对象:如何使用sinon.fakeServer与请求主体进行响应?
server.respondWith(response);
[...]
当响应是
Function
,它会被传递请求对象。您必须手动调用响应才能完成请求。
但天真的方法似乎并不工作:
const server = sinon.server.create();
server.respondWith(request => request.requestBody);
(抛出响应,在我的摩卡套房错误)。