- make test still exists, so if you have been using it, as well as make test-watch, they should all work exactly the same. - [Changed] As part of the check stage, Jenkins will run Lint and Unit Tests in parallel. Integration Tests run later because running them at the same time as Unit Tests caused errors. - [Added] "make unit-test" and "make unit-test-watch" run unit tests only. Watching all unit tests is faster now because we ignore integration tests and we only compile shadow-cljs :mock target once. We are at approximately 10-15s to re-run all unit tests after saving a watched file, depending on your hardware. If you change mocks.js_dependencies.cljs, you must re-run the make target. - [Added] "make integration-test" and "make integration-test-watch" run integration tests only. These are much slower than the unit tests. Fixes https://github.com/status-im/status-mobile/issues/18112
2.0 KiB
Local testing
Unit & integration tests
To run tests:
make test
Also test watcher can be launched. It will re-run the entire test suite when any file is modified
make test WATCH=true
Developers can also manually change the shadow-cljs option :ns-regex
to control which namespaces the test runner should pick.
Testing with REPL
The most convenient way to develop and run test locally is using REPL:
- Run command
make test-watch-for-repl
. - Once you see the message
[repl] shadow-cljs - #3 ready!
you can connect a REPL to the:test
target from VS Code, Emacs, etc. - In any test namespace, run cljs.test/run-tests or your preferred method to run tests in the current namespace.
You can run single test in REPL like this
(require 'cljs.test)
(cljs.test/test-var #'status-im.data-store.chats-test/normalize-chat-test)
Tests will use the bindings in modules/react-native-status/nodejs
, if you make any changes to these you will need to restart the watcher.
Example in Emacs
In the video below, you can see two buffers side-by-side. On the left the source implementation, on the right the REPL buffer. Whenever a keybinding is pressed, tests in the current namespace instantly run. You can achieve this exact flow in VS Code, IntelliJ, Vim, etc.
Example in terminal emulator
Here I'm showing a terminal-only experience using Tmux (left pane Emacs, right pane the output coming from running the make target).
Component tests
To run tests:
make component-test
Also test watcher can be launched. It will re-run the entire test suite when any file is modified
make component-test-watch
Check component tests doc for more.