1. Feb 3rd, 2011

    Testing with Expresso and Zombie.js

    Node Tutorial Part 11, in which Alex tests the Nodepad app using Expresso and Zombie.js. Here’s a sampler:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    function start() {
      exports['test login'] = function() {
        zombie.visit('http://localhost:3001/', function(err, browser, status) {
        // Fill email, password and submit form
        browser.
          fill('user[email]', 'alex@example.com').
          fill('user[password]', 'test').
          pressButton('Log In', function(err, browser, status) {
            // Form submitted, new page loaded.
            assert.equal(browser.text('#header a.destroy'), 'Log Out');
            teardown();
          });
        });
      };
    }

    PS If you don’t already know of DailyJS, it’s a great resource for all things JavaScript.

    Your comment, here ⇓