Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
WEB APP TESTING USING KNOCKOUT.JS

You're reading from   WEB APP TESTING USING KNOCKOUT.JS Design, implement, and maintain a fully tested JavaScript web application using Knockout.JS

Arrow left icon
Product type Book
Published in Nov 2014
Publisher
ISBN-13 9781783982844
Pages 154 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
ROBERTO MESSORA ROBERTO MESSORA
Author Profile Icon ROBERTO MESSORA
ROBERTO MESSORA
Arrow right icon
View More author details
Toc

Setup and teardown


It's important to understand that the describe and it global functions will not only contain specifications and expectations respectively. It's always necessary to add some more code to set up the complete and working tests, for example, code needed to implement all the objects involved in what we are verifying and all the method calls that trigger the specifications events that we need to stress on.

There are two Jasmine global functions that help setting up a proper test execution environment: beforeEach and afterEach. Like every other unit testing framework, Jasmine provides these two functions to set up and teardown a specification context. In the beforeEach function, we have to write all the code needed to create and initialize all the objects that we need to execute a single specification. The afterEach function is used to reset all these objects. They both take a function as a single argument, which will be executed by the spec runner.

Jasmine calls these two functions...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime