QUnit uses a set of top-level functions to provide semantic meaning in unit tests.
Just like most of the unit test frameworks, it follows an arrange-act-assert pattern, a common test pattern employed during unit testing. Its purpose is to make a clear distinction between the set up for the test, the action that is to be tested, and the evaluation of the results.
Let's take a look at the important constructs.
Summary of Important Constructs
| Construct | Usage |
|---|
| module | module(string) - defines a module. |
| test | test(string, function) - defines a test. |
| ok | ok(boolean, string) - validates to true or false. |
| equal | equal(value1, value2, message) - compares two values, using the double-equal comparator. |
| deepEqual | deepEqual(value1, value2, message) - compares two values based on their content, not just their identity. |
| strictEqual | strictEqual(value1, value2, message) - strictly compares two values, using the triple-equal comparator. |