Jasmine 茉莉花&x2B;sinon fakeserver

Jasmine 茉莉花&x2B;sinon fakeserver,jasmine,sinon,Jasmine,Sinon,所以…我正在用Jasmine为我的GraphQL控制器编写测试。然后,控制器依赖于另一个文件中的fetcher函数,该函数向WordPress请求数据,然后将数据转换为GraphQL模式 我担心我对如何实现sinon fakeserver的理解可能不够全面 describe('graphql article by slug', function () { var server; beforeEach(() => { server = sinon.fakeServer.c

所以…我正在用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();
      });
  });

});
当我运行上述测试时,我始终得到:


错误:超时-在jasmine指定的超时时间内未调用异步回调。默认超时时间间隔。
您需要调用
服务器.respond()
要完成请求,请查看