Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jasmine 如何等待服务结果得到?_Jasmine - Fatal编程技术网

Jasmine 如何等待服务结果得到?

Jasmine 如何等待服务结果得到?,jasmine,Jasmine,我非常确定我在下面使用的person服务的get函数返回一个函数,但是我的测试似乎没有执行任何一个分支,所以它超时了。这是否意味着get不返回承诺 describe('person service', function () { beforeEach(module('tournament')); var person; beforeEach(inject(function (_personService_) { person = _personService_; })

我非常确定我在下面使用的person服务的get函数返回一个函数,但是我的测试似乎没有执行任何一个分支,所以它超时了。这是否意味着get不返回承诺

describe('person service', function () {
  beforeEach(module('tournament'));

  var person;

  beforeEach(inject(function (_personService_) {
    person = _personService_;
  }));

  it('should get person data', (done) => {
    var expectedPerson = [
      { id: 2, last: 'Steigerwald', first: 'Michael' },
    ];

    person.get(2).then( 
      (result) => {
        expect(result).toEqual(expectedPerson);
        done();
      },
      (reason) => {
        console.log(reason.message);
        done();
      }
    );
  });
});


是的,
person.get(2)
没有返回承诺,这就是测试超时的原因。您能否检查
person.get()
是否是承诺?根据Chrome开发工具,person.get()的结果确实是承诺。