Closed jasonmacdonald closed 8 years ago
You are right! I'll fix it. You might be able to import from 'ng-forward/testing' as well.
Damn, you're fast. I was still editing my post lol.
And no, using 'ng-forward/testing' gives the same error, "cannot find symbol'.
Found another error in the docs. :( Inside the createAsync callback, you must call done(); or Jasmine will always return "true" for the expectation. Also, need to add variable "done" to the "it" call to gain access to the done method...
it('should have name', (done) => {
let html = '<home></home>';
// Use tcb to override templates and providers, then create your fixture.
tcb
.overrideTemplate(Test, html)
.createAsync(Test).then(fixture => {
let homeComp = fixture.componentInstance;
expect(homeComp.name).toEqual('Home');
done();
});
});
I know the Docs say this isn't an actual async call, but Jasmine seems to be treating it as one. Perhaps the Promise is enough for it to escape the event loop? Either way, probably best to treat it like one so when you switch to Angular2 (and it becomes async) the test will be ready. :)
Yup you are right.
I think there might be an error in the docs about testing. It says to import TestComponentBuilder from 'ng-forward', but that returns a "cannot resolve symbol' error. I checked and the index.d.ts does not import that file. It seems I have to import it from 'ng-forward/cjs/testing'. Is this correct, or did I do something wrong?
Here's a quick example. The first import gives an error, the second one doesn't.