diff --git a/deps.edn b/deps.edn index c44e9d7d35..5cc54c1440 100755 --- a/deps.edn +++ b/deps.edn @@ -43,6 +43,7 @@ :test {:extra-paths ["src/test/"] :extra-deps {org.clojure/clojurescript {:mvn/version "1.10.879"} org.clojure/test.check {:mvn/version "1.1.1"} + org.clojars.lucywang000/shadow-test-utils {:mvn/version "0.0.2"} org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}} :main-opts ["-m" "shadow.cljs.devtools.cli"]} diff --git a/docs/dev-practices.md b/docs/dev-practices.md index 78e69807aa..ea2110ba66 100644 --- a/docs/dev-practices.md +++ b/docs/dev-practices.md @@ -53,12 +53,41 @@ To configure the linter, see its `config` var. ## Testing -We have unit and end to end tests as described in https://github.com/logseq/logseq#5-run-tests. +We have unit and end to end tests. + +### End to End Tests + +To run end to end tests + +``` bash +yarn electron-watch +# in another shell +yarn e2e-test # or npx playwright test +``` ### Unit Testing -When writing unit tests it is helpful to have tests automatically run on file -save with `yarn shadow-cljs watch test --config-merge '{:autorun true}'`. The -test output may appear where shadow-cljs was first invoked e.g. where `yarn -watch` is running. For more about the shadow-cljs test runner, see [this -documentation](https://shadow-cljs.github.io/docs/UsersGuide.html#_testing). +Our unit tests use the [shadow-cljs test-runner](https://shadow-cljs.github.io/docs/UsersGuide.html#_testing). To run them: + +```bash +yarn test +``` + +There are a couple different ways to develop with tests: + +#### Autorun Tests +To run tests automatically on file save, run `yarn +shadow-cljs watch test --config-merge '{:autorun true}'`. The test output may +appear where shadow-cljs was first invoked e.g. where `yarn watch` is running. +Specific namespace(s) can be auto run with the `:ns-regexp` option e.g. `npx +shadow-cljs watch test --config-merge '{:autorun true :ns-regexp +"frontend.text-test"}'`. + +#### Focus Tests + +Tests can be automatically compiled and then selectively run on the commandline +using https://github.com/lucywang000/shadow-test-utils. For this workflow: + +1. Run `clj -M:test watch test` in one terminal +2. Focus a test by adding a `^:focus` metadata flag +3. In another terminal, run `node node static/tests.js` diff --git a/docs/develop-logseq.md b/docs/develop-logseq.md index 9a9d573f76..723016de22 100644 --- a/docs/develop-logseq.md +++ b/docs/develop-logseq.md @@ -23,22 +23,6 @@ Open . yarn release ``` -### 5. Run tests - -Run ClojureScript tests - -```bash -yarn test -``` - -Run E2E tests - -``` bash -yarn electron-watch -# in another shell -yarn e2e-test # or npx playwright test -``` - ## Desktop app development ### 1. Compile to JavaScript @@ -63,4 +47,4 @@ yarn dev-electron-app ```bash yarn release-electron -``` \ No newline at end of file +```