Suites and specifications
In the previous example, we saw that Jasmine is quite simple to use, even if we decided not to express our tests in a real BDD style. Its working pattern is always defined by a sequence of suites that contains a sequence of specifications, which, in turn, contains one or more expectations.
Suites
The describe
Jasmine global function defines a suite that we can describe as a container for a given broad context (or more generally, if we don't want to think in BDD, a logical specifications grouping):
describe("a suite or context for specifications", function () {
//a sequence of specifications
});
The describe
function accepts two arguments: a string representing a sentence that expresses the suite/context and a function that contains all the code needed to execute the suite itself, mostly specifications.
It's also possible to nest in the suites calling one or more describe
functions inside a parent describe
function. This is useful when you have...