Now, we come to write the Jasmine tests for our weather application. Actually, after you know how to write Jasmine tests for both synchronous and asynchronous JavaScript code and how to load the HTML fixtures in your Jasmine tests from the previous sections, testing the weather application is an easy task. As you may remember we have three major JavaScript objects in the weather application that we need to write unit tests for: the LoginClient
, RegistrationClient
, and WeatherClient
objects.
One of the best practices that I recommend is to separate the JavaScript source and testing code as shown in the preceding screenshot. There are two parent folders, one for the JavaScript source, which I call js-src
folder, and the other for the JavaScript tests, which I call js-test
folder. The js-test
folder contains the tests written by the testing frameworks that will be used in this book; for now, it contains a jasmine
folder that includes the Jasmine tests.
As indicated...