0
所以......我正在用Jasmine爲我的GraphQL控制器編寫測試。然後控制器依賴於另一個文件中的fetcher函數,該文件向數據請求WordPress,然後將其轉換爲GraphQL模式。Jasmine + sinon fakeserver
我擔心我可能對如何實施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.