Writing Jasmine tests for exceptions
In this recipe, you will learn to write Jasmine tests for JavaScript exceptions using the toThrow() and toThrowError() matchers. Also, you will learn how to write Jasmine tests to validate user-defined messages.
To write the Jasmine test for Exceptions, let's assume that you are developing an application for <ABC> company. Currently, you are developing an error handling module, which handles user-defined or system errors.
"As a JavaScript developer, I want to handle all the errors and validate error messages so that the end user should not get stuck during any process."
Let's consider some scenarios in the current context, that is, all the system and user-defined errors should be handled throughout the application: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access