Skip to content

Testing

We use Codeception for testing, especially testing the php code.

Useful commands and common pitfalls

Useful commands for testing and common pitfalls.

CommandActionPitfall
amOnPageChanges URL, loads page, waits for body visibleDo not use to assert being on a URL
amOnSubdomainChanges internal URL stateDoes not load a page
amOnUrlChanges internal URL stateDoes not load a page
clickFires JavaScript click eventDoes not wait for anything to happen afterwards
seeCurrentUrlEqualsChecks on which URL the browser is (e.g. after a redirect)
submitFormFills form details and submits it via click on the submit buttonDoes not wait for anything to happen afterwards
waitForElementWaits until a specific element is available in the DOM
waitForPageBodyWaits until the page body is visible (e.g. after click is expected to load a new page)

Running tests

Run the tests with:

bash
./scripts/test-backend

or

bash
./scripts/test-backend Api SearchApiCest

or to run a specific test

bash
./scripts/test-backend Api SearchApiCest:canOnlySearchWhenLoggedIn

If you want to run with debug mode turned on, then use

bash
./scripts/test-backend --debug

To stop the Test containers run ./scripts/stop test.

We are working on restructing the code to enable unit testing.

The test contains stay around after running, and you can visit the test app in your browser, and it has it's own phpmyadmin.

Writing unit tests

CodeCeption uses PHPUnitTests under the hood and therefore the PHPUnit test documentation can be helpful.