O'Reilly logo

Jasmine Cookbook by Munish Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required