All our tests are all located inside test.js.
They can be run with:
cd web
npm test
The dynamic website tests also uses Mocha just like the tests for OurBigBook CLI and OurBigBook Library, so similar usage patterns apply, e.g. to run just a single test:
npm test -- -g 'substring of test title'
or to show database queries being done in the tests:
DEBUG='*:sql:*' npm test
To run the tests on PostgreSQL instead of SQLite, first setup as in local run as identical to deployment as possible, and then:
npm run test-pg
npm run deploy-prod
Note that this will erase all data present in the database used. In order to point to a custom database use:
DATABASE_URL_TEST=postgres://realworld_next_user:a@localhost:5432/realworld_next_test npm run test-pg
We don't use DATABASE_URL when running tests as a safeguard to reduce the likelihood of accidentally nuking the production database.
The tests include two broad classes of tests: