我计划编写多个模拟的Web请求响应并将其存储为JSON格式。这是一个好的实践吗?我不使用以下类似的spy,因为我的JSON文件太长了,不方便适配到代码中。
it('should send post params in request body', function() {
var params = { foo: 'bar' };
var expected = JSON.stringify(params);
var request = new PassThrough();
var write = sinon.spy(request, 'write');
this.request.returns(request);
api.post(params, function() { });
assert(write.withArgs(expected).calledOnce);
});