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
npm test
Types of Testing¶
There are two types of unit tests in the AppRun application.
- Test the events-states - publishing the events and asserting the states.
- 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="https://unpkg.com/apprun@latest/dist/apprun-dev-tools.js"></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.
Examples¶
Please check out the unit tests from the AppRun RealWorld example application.
You can find: