Skip to content

Unit Testing

AppRun architecture is unit test-oriented. The three architectural parts state, view, and update (event handlers) are decoupled. They are straightforward to test.

AppRun development environment includes the Jest framework. The convention to run the tests is to use the npm script:

npm run jest
We can also run the Jest testing interactive mode using the npm script:
npm test
Jest watches file changes and runs the test files only related to changed files. Jest also executes the tests in parallel. Therefore, it is very fast to execute the tests. The interactive way for us to define which tests to be executed during the watch mode.

Types of Testing

There are two types of unit tests in the AppRun application.

  1. Test the events-states - publishing the events and asserting the states.
  2. Test the state-vdom - set the states and assert the VDOM output of the view function.

Create Tests using CLI

Creating unit tests could be tedious, but you can use the AppRun Dev Tools to generate the tests.

First, include the CLI scripts in your HTML.

<script src=""></script>

Event-State Tests

Use the create-event-tests command to create event-state tests.

State-VDOM Tests

Use the create-state-tests (start|stop) command to create state-view tests.


Please check out the unit tests from the AppRun RealWorld example application.

You can find: