Tooling

All of our unit tests are written using Jasmine, a popular JavaScript unit test module. Jasmine offers:

You'll want to become familiar with how Jasmine works, as we use it extensively.

We also use a home-grown add-on called Jasmine-Suites, which allows us to have multiple test files all contribute to the same nested test namespaces (so that multiple test suites can populate, say, the admin/views/ test namespace).

Writing New Tests

Our JavaScript tests sit beside the implementation files, nested under tests/ directories. So for instance, the Review Board API resource classes live in reviewboard/static/rb/js/resources/models/, while their tests live in reviewboard/static/rb/js/resources/models/tests/.

Files should contain the module name being tested, with a Tests suffix. For instance, the tests for reviewModel.es6.js should be named reviewModelTests.es6.js.

If you're introducing a new tests file, you will need to ensure that it's found by the test runner. This requires adding to a js-tests static media bundle for the project (found in djblets/staticbundles.py for Djblets and reviewboard/staticbundles.py for Review Board).