How to mock ViewController.willEnter() in tests?

Back in RC4, I was doing something like mocking our the View Controller class with these methods to emulate firing “willEnter()” in my tests:

export class ViewControllerMock() {
    viewEnter: Subject<any> = new Subject;

    public get willEnter(): Subject<any> {
       return this.viewEnter;

I was able to do this in my specs:;

Which would make the functions that are inside the willEnter block run.

This doesn’t work anymore, and simply calling viewCtrl.willEnter.emit(true) will cause my other components that I’m not testing to call their functions, even if I’m doing fixture.destroy() on them.

1 Like