-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to mock ViewController.willEnter.subscribe? #190
Comments
Where are you importing Observable from? http://stackoverflow.com/questions/36568388/observable-of-is-not-a-function |
@kamok willEnter is not a function but an Observable to which you can subscribe. In your mock you can declare it either as a property and set it to and Observable or even better as a getter. you can just write
This will emit a single "marble" with the value |
@masimplo - legend. |
@masimplo That did the trick. Thank you. Posted on stack and nobody knew what to do. |
When testing components that utilizes the viewController, you must mock the viewController using a viewControllerMock. By the standards of this seeder project, we are placing that class in mock.ts, and importing it in test.ts.
However, I'm having trouble mocking the
willEnter()
method, as even when I return an Observable, as per the docks, it's giving me aTypeError: viewCtrl.willEnter.subscribe is not a function
.Has anyone successfully mock these Observables in their app?
Here's my attempt at writing a function that returns an Observable, which returns true when subscribed to it.
The text was updated successfully, but these errors were encountered: