You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version are you using?
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
What environment are you running Jasmine in (node, browser, etc)?
Angular 4.0.1 via angular cli
How are you running Jasmine (standalone, npm, karma, etc)?
ng test
If possible, include an example spec that demonstrates your issue.
I have a login page which call authentication service to authenticate the users. If there user's credentials are invalid then it throws an observable error back to login method (which is of type void).. The unit test is throwing uncaught exception like..
Failed: Uncaught (in promise): The username or password is invalid
I have tried to use following but it didn't help
expect(app.login()).toThrow( new Error("The username or password is invalid"));
The text was updated successfully, but these errors were encountered:
Assuming that app.login() is the thing that is throwing the Error, I think you probably want something more like:
expect(function(){app.login();}).toThrowError("The username or password is invalid");
When you use expect(app.login()), the login function is already called and its output is passed to expect.
In the future, you are more likely to get quicker responses from the community for "How to use jasmine?" questions and a history of other solutions on the jasmine-js group. We try to keep jasmine's github issues list focused on bugs and feature requests for jasmine itself.
What version are you using?
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
What environment are you running Jasmine in (node, browser, etc)?
Angular 4.0.1 via angular cli
How are you running Jasmine (standalone, npm, karma, etc)?
ng test
If possible, include an example spec that demonstrates your issue.
I have a login page which call authentication service to authenticate the users. If there user's credentials are invalid then it throws an observable error back to login method (which is of type void).. The unit test is throwing uncaught exception like..
Failed: Uncaught (in promise): The username or password is invalid
I have tried to use following but it didn't help
expect(app.login()).toThrow( new Error("The username or password is invalid"));
The text was updated successfully, but these errors were encountered: