|
@@ -88,6 +88,10 @@ Our unit tests use the [shadow-cljs test-runner](https://shadow-cljs.github.io/d
|
|
|
yarn test
|
|
|
```
|
|
|
|
|
|
+By convention, a namespace's tests are found at a corresponding namespace
|
|
|
+of the same name with an added `-test` suffix. For example, tests
|
|
|
+for `frontend.db.model` are found in `frontend.db.model-test`.
|
|
|
+
|
|
|
There are a couple different ways to develop with tests:
|
|
|
|
|
|
#### Focus Tests
|
|
@@ -115,6 +119,17 @@ To run tests automatically on file save, run `clojure -M:test watch test
|
|
|
the `:ns-regexp` option e.g. `clojure -M:test watch test --config-merge
|
|
|
'{:autorun true :ns-regexp "frontend.util.page-property-test"}'`.
|
|
|
|
|
|
+#### Database tests
|
|
|
+
|
|
|
+To write a test that uses a datascript db:
|
|
|
+
|
|
|
+* Be sure your test ns has test fixtures from `test-helper` ns to create and
|
|
|
+ destroy test databases after each test.
|
|
|
+* The easiest way to set up test data is to use `test-helper/load-test-files`.
|
|
|
+* For the repo argument that most fns take, pass it `test-helper/test-db`
|
|
|
+
|
|
|
+For examples of these tests, see `frontend.db.query-dsl-test` and `frontend.db.model-test`.
|
|
|
+
|
|
|
## Logging
|
|
|
|
|
|
For logging, we use https://github.com/lambdaisland/glogi. When in development,
|