Step 3: Write the Tests
We are going to keep it simple when it comes to testing this JavaScript code. We’re going to start with the model and verify that it can read those page elements correctly. Then we’ll shift gears and test the controller actions, verifying they’re doing what we expect them to do.
The testing framework we are going to use here is called Jasmine.[8] It’s one of the more popular JavaScript unit testing frameworks, but it is by no means the only one. We are also going to use another third-party library called jasmine-jquery,[9] which helps Jasmine and jQuery play nicely together.
OK, ready? Let’s do this, starting with the model.
The Model
JavaScript unit tests are just like any other kind of unit test in that there is usually ...
Get The Way of the Web Tester now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.