【发布时间】:2016-02-04 20:19:57
【问题描述】:
所以...我正在 Jasmine 中为我的 GraphQL 控制器编写测试。然后,控制器依赖于另一个文件中的 fetcher 函数,该函数向 WordPress 发出数据请求,然后将其转换为 GraphQL 模式。
我担心我可能对如何实现 sinon fakeserver 的理解不完全。
describe('graphql article by slug', function () {
var server;
beforeEach(() => {
server = sinon.fakeServer.create();
});
afterEach(() => {
server.restore();
});
it('should return the expected graphql result', function (done) {
var server = sinon.fakeServerWithClock.create();
server.respondWith(wpEndpoint, JSON.stringify(wpData()));
graphqlController
.loadJSON(request)
.then(function (result) {
console.log('result', result);
console.log('expectedData', expectedData());
expect(JSON.parse(result)).toEqual(JSON.parse(expectedData()));
done();
});
});
});
当我运行上面的测试时,我一直得到:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
【问题讨论】: