0

我想做以下事情:

describe('Questions', () => {
    var rest: RestService;
    var mockBackend: MockBackend;

    beforeEach((done) => {
        console.log('Executing before each');
        inject([RestService, XHRBackend], (_rest: RestService, _mockBackend: MockBackend) => {
            rest = _rest;
            mockBackend = _mockBackend;
            console.log('This never gets executed');
            done();
        });
    });

 ....

回调注入永远不会被调用。我是否遗漏了什么,或者这必须是一个更复杂的解决方案?

4

1 回答 1

0

我想应该只是

describe('Questions', () => {
    var rest: RestService;
    var mockBackend: MockBackend;

    beforeEach(inject([RestService, XHRBackend], (_rest: RestService, _mockBackend: MockBackend) => {
            rest = _rest;
            mockBackend = _mockBackend;
            console.log('This never gets executed');
    });
});

取决于您的 Angular2 版本。

于 2016-06-09T05:29:46.153 回答