Test suites

Following the best practices, you have to separate your tests that are similar to be grouped in suites. For example, in our application, we will write code to manage football matches and information about teams. Both matches and teams are different domains and for that reason, we should group the tests related to the matches in a suite and repeat the same for teams.

Following the example where we created an add function, we might be implementing this function for a Calculator application, so let's use this as an example to understand Jasmine. In the specs folder, create the calculator.spec.js file and write the following code:

describe("Calculator", function() {

...

});

We have created our test suite; for that, we are using the describe function and we pass the name of our suite as the first parameter, in this case Calculator, and as the second parameter, we pass a function that will contain the code for our test cases.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset