Follows the execution of a page/an app by expecting messages (sent via
alert()) by running it in PhantomJS.
Tracks that your app as a whole works as you expect it.
The piece of cake that was missing in your integration testing strategy!
This is very useful for integration testing, when you want to make sure that your components fit well one with the other.
Because mocking in your unit tests is not enough, you have to check against real production code in integration tests.
It can also easily be used as a monitoring tool if you have a long-running app, or want to ensure your freshly deployed app fulfills its most basic (therefore critical!) tasks.
Clouseau tracks invariants in a live and running app in phantomJS. Basically, this is integration testing, which means you should be able to find those invariants without any modification of your codebase. Though it might be necessary from time to time, of course...
You define those invariants by defining functions, and decide how they should flow one with the other with the help of Q.
Find the page/app in which you want to test the invariants
clouseau in your project by running
npm install clouseau-js
Build a Node.js script that uses
clouseau as follows:
var clouseau = require'clouseau-js';returnvar dfd = this; // `this` is a deferred! \o/if txt !== expectedMessagereturn dfdreject"Unexpected message: " + txt;return dfdresolvepage;;;var check1 = clouseauaddCheckpointalertCheck'MESSAGE 1' 10000; // timeout in msvar check2 = clouseauaddCheckpointalertCheck'MESSAGE2' 40000;var url = ""clouseaustarturlthencheck1thencheck2then console.log'OK'; console.log'Fail'; ;
The module exports 3 properties:
Q: The very excellent Q library
addCheckpoint(fn, timeout): To add your own checkpoint
start: Start loading the page in PhantomJS and verifying the checkpoints