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 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
Installation instructions.
Commands¶
The following commands are available to you:
gulp tests
runs the entire test suitegulp tests:unit
only runs the unit testsgulp tests:integration
only runs the integration testsgulp tests:watch
to start karma to watch unit tests
Naming¶
The naming for tests should adhere to the conventions established in General and 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
Unit Tests and 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 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 Unit Tests or 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.