Quick Test Automation with CasperJS

I find myself as the sole QA Engineer at a rapidly changing startup needing to automate integration tests.  There are legacy Capybara tests in our large Sinatra app, some javascript unit tests, and a bevy of test suites for the remainder of the stack. But, like any software product, its codebase grows faster than the test suite.

In looking for a quick way to get repeatable manual tests of the web application front end I settled on CasperJS.  Partly because of the speed of implementation, and the familiarity of Javascript and some robust features like great command line tools.

npm install casperjs --devel

And you’re on your way!

A great use i’ve found for casper scripts is to quickly hit all of the accessible dynamic FE page types we have and check for a 200 status to help regression test very quickly.

casper.test.begin('johanncodes.com returns an OK status', 1, function(test) {
    casper.start('https://johanncodes.com/', function() {
        test.assertHttpStatus(200);
    }).run(function() {
        test.done();
    });
});

Another great feature i’ve made use of is CasperJS’ great form fill and submission ability, which lets me easily work through tasks like user account creation, user profile changes, navigation through checkout flows and other fun things.

Even with very rudimentary javascript knowledge you can start to build very powerful tests and scripts almost immediately.  If you’re looking to automate very rote parts of your QA flow that have a binary success/fail state you can check for CasperJS is worth a look.

Check out the docs and installation instructions.

Happy testing!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s