Test add-ons in Volto 18

Test add-ons in Volto 18#

Warning

This guide assumes that you've used Cookieplone to create your add-on boilerplate.

Volto uses Jest for unit tests. You can create unit tests for testing your add-on.

Run the following command.

make test

Override Jest configuration#

In CI or for testing add-ons, it's useful to modify Jest's package.json configuration file. You can use the file jest.config.js provided by the boilerplate. The test command will load it and apply it.

Warning

Do not modify the existing keys in there if you don't know what you are doing, since some of them are required for the tests to run properly in the Volto context.

Both configurations are merged in a way that the keys of the configuration provided override the initial package.json configuration, either in Volto or in your projects.

Note

For more background on testing add-ons in Volto 18, see Testing, since the developer experience has been unified for both add-ons and Volto core.

Acceptance tests#

Use Cypress to run acceptance tests.

To start the backend server, run the following command. This will start a Docker container with a vanilla Plone backend.

make acceptance-backend-start

To start the frontend acceptance server in development mode, run the following command.

make acceptance-frontend-dev-start

You can run the frontend in development mode, so you can develop while writing tests. Run the following command to run Cypress tests afterward.

make acceptance-test