---
myst:
html_meta:
"description": "Testing add-ons"
"property=og:description": "Testing add-ons"
"property=og:title": "Testing add-ons"
"keywords": "Volto, Plone, Testing, CI, Add-ons"
---
# Testing add-ons
We should let jest know about our aliases and make them available to it to
resolve them, so in `package.json`:
```{code-block} json
:emphasize-lines: 6
"jest": {
"moduleNameMapper": {
"@plone/volto/(.*)$": "/node_modules/@plone/volto/src/$1",
"@package/(.*)$": "/src/$1",
"@plone/some-volto-addon/(.*)$": "/src/addons/@plone/some-volto-addon/src/$1",
"my-volto-addon/(.*)$": "/src/addons/my-volto-addon/src/$1",
"~/(.*)$": "/src/$1"
},
```
You can use `yarn test src/addons/addon-name` to run tests.
## Jest configuration override
In CI or for testing addons, it's interesting to provide an alternate Jest configuration
or slightly modify it. Volto provide a way to do it using a `jest.config.js` file or
pointing the test runner to a file of your choice, using `RAZZLE_JEST_CONFIG`
environment variable.
```shell
RAZZLE_JEST_CONFIG=my-custom-jest-config.js yarn test
```
```{note}
Both configurations are merged in a way that the keys of the config provided override the initial (`package.json`) default config, either in Volto or in your projects.
```
This is specially useful in CI while developing add-ons, so you can pass an specific configuration that deals with the addon config properly.
## Testing add-ons in isolation
Testing an add-on in isolation as you would do when you develop a Plone Python backend add-on can be a bit challenging, since an add-on needs a working project in order to bootstrap itself.
There are some utilities available in order to help bootstrap a testing environment for isolated add-ons.
(plone-scripts-label)=
### `@plone/scripts`
This library adds some useful command line utilities that come in handy when testing add-ons in isolation.
First of all, your add-on should has `@plone/scripts` as dependency:
```json
"dependencies": {
"@plone/scripts": "*",
}
```
Once done, your environment has an executable `addon` available which exposes a command line interface and you could run:
`npx -p @plone/scripts addon clone [options]