Skip to main content

Pixwel API - testing

You should aim for 100% code coverage of any code that you touch. There are two suites of tests in the Pixwel API:
  1. Kahlan tests - Kahlan is nice, we like Kahlan.
  2. Legacy tests - older tests in the default li3 testing tool.
See this article for how we manage running legacy tests together with Kahlan tests.

Kahlan tests

or

Code coverage

See also xdebug
Coverage: by method
Coverage: line-by-line
Note: The CI build actually collates together legacy and kahlan test coverage.
The following will created an HTML coverage report:
The coverage report may be viewed in your browser at

Best practise for Pixwel with Kahlan

To make sure performance is good:
  • Prefer Stubbing over Fixtures - Fixtures are slow.
  • If you MUST use fixtures:
    • Make sure it’s compartmentalised and the tests that do not need fixtures are in a separate context block to the ones that do
    • Only use the exact fixtures that are needed - don’t blindly load them all
  • Prefer before over beforeEach where possible

Legacy tests

Older li3 tests live in api/tests/. They are no longer run in CI (only Kahlan is), but can still be run from the app container:

Back to docs index | API docs index | Next page in recommended reading order >>