Testing
Tests are locatet in ./test folder, and follow project structure for
convenience:
├─ test/
│ ├─ client/ # UI tests
│ ├─ models/ # Unit tests
│ └─ server/ # Integration (RPC) tests
Nodeca exposes some global variables & helpers both on server and client envicoment, to simplify tests writing.
Sources for addons are here: https://github.com/nodeca/nodeca.core/tree/master/lib/test.
Server env
TEST.N-N.TEST.browser- patched instance of Nightmare (to write client side tests).
Nightmare is patched, to use specific nodeca features.
Overriden Nightmare methods:
.goto(url)- url can be a function
- wait for client initialization (
NodecaLoader.booted) - install client asserts interceptor
- set viewport to 1600x1200
refresh()- the same additional actions as
.goto()does.
- the same additional actions as
Additional Nightmare methods:
.evaluateAsync(func, callback [, arg1, arg2...])- seeevaluateNightmare's docs for details..auth(login, callback)login- nickname or User object. Creates user if not exists and login. Logout on empty value.callback(user)- optional, function to call after success.
Client env
TEST.N-Nassert- Chai assert. You can do asert in any part of client code. It will be pased to server and processed by testing suite.trigger- Helper to click selector and listen specific N.wire channel to detect operation end. That's more convenient and effective, than use Nightmare's.wait().