There are current two ways to run tests, using either PostgreSQL or SQLite.
- Install Docker
- Run redis and postgres using docker compose:
docker compose up
- Create the test database:
./dev-tools/create-test-database
- Run
yarn test
- Install PostgreSQL - Tips to installing Postgres
- In PostgreSQL, create a database and user named "spoke_test":
CREATE DATABASE spoke_test;
CREATE USER spoke_test WITH PASSWORD 'spoke_test';
GRANT ALL PRIVILEGES ON DATABASE spoke_test TO spoke_test;
- Run
yarn test
- Run
yarn run test-sqlite
Redis is used for caching and is separate from the backend DB so can be used with sqlite or postgres. Redis cache testing defaults to postgres and functions like an 'addon' to the DB for improved speed/scalability.
- Run
yarn test-rediscache
The integration test suite automates real world user scenarios to verify that Spoke behaves as intended. The integration testing suite uses Cypress to drive a web browser to test user experience scenarios. It runs a separate test instance of Spoke, configured separately from the config in your .env
, using the spoke_test
PostgreSQL database, and running at http://localhost:3001
.
To run the integration test suite in development:
- Set up PostgreSQL as described above
- Start test instance of Spoke with
yarn start:test
- Run integration test suite interactively with
yarn test-cypress
The integration suite runs in CI using a Github Actions workflow defined in .github/workflows/cypress-tests.yaml
.
When developing new features for Spoke, please consider writing a Cypress tests. The test server will hot reload your code changes so that you can test drive your feature development.