This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
120 lines (84 sloc) 3.45 KB

General

We use two kinds of tests: unit and integration tests. Unit tests are simple test cases, that test a single piece of functionality within a given JavaScript file in an isolated environment without the DOM. Integration tests test the users interaction following certain move, click and keyboard interactions.

This testing infrastructure includes them both with Jasmine as the test suite and Karma as the test runner for unit tests. Protractor serves as the integration tests framework. Both tests can be run separately as described in :ref:`testing_commands` below.

All tests are located within /tests. Each pull request is validated on Travis, which runs the test executing the gulp tests command. You can also run this command locally, if you followed the :doc:`/general/installation` instructions.

Commands

The following commands are available to you:

  • gulp tests runs the entire test suite
  • gulp tests:unit only runs the unit tests
  • gulp tests:integration only runs the integration tests
  • gulp tests:watch to start karma to watch unit tests

Naming

The naming for tests should adhere to the conventions established in :doc:`/guidelines/general` and :doc:`/guidelines/javascript`.

Unit tests should be prefixed using test before the name file name and integration tests use spec. For example:

test.header.js
test.footer.js
test.content.typography.js
test.content.wysiwyg.js
...
spec.header.js
spec.footer.js
spec.content.typography.js
spec.content.wysiwyg.js
...

Structure

Unit tests are located within /tests/unit and integration tests within /tests/integration to create a clear separation. There are several configuration files available within the /tests directory described in :doc:`/testing/unit_tests` and :doc:`/testing/integration_tests` respectively.

The starting structure looks like this:

tests/
├─ fixtures/
├─ integration/
├─ unit/
├─ base.conf.js
├─ karma.conf.js
└─ protractor.conf.js

Fixtures and coverage are described in more depth within :doc:`/testing/unit_tests`.

Configuration

The configuration files are located at the root of the /tests folder. karma.conf.js defines the settings for the gulp tests:unit command and protractor.conf.js for the gulp tests:integration command.

The function of these configuration files is described in more depth within :doc:`/testing/unit_tests` or :doc:`/testing/integration_tests`.

Browserslist

Browserslist enables us to provide a compiled and ready to use browser-list to services such as Sauce Labs, Autoprefixer and more.

Simply add the required browser to the browserslist file. Our configuration includes the last 2 versions and ie >= 9.

Local Server

You need to be able to run django to start a local server:

  • run cd tools/server
  • run make install to setup the server
  • run make run to start the server

the development server will be reachable on http://0.0.0.0:8000/