UI End-to-End Testing with Nightwatch.js

Good morning and Happy Friday! I’m back after a little prompting from an old friend.

Song of the day:

Quick life update: I’m living near New York City now, and I’m working as a Senior Software Engineer for a team that writes the software that supports such excellent blogs as Engadget, Huffington Post Australia (more international editions to follow!), and Autoblog, among many others.

I’ve also gotten way into 3D printing, Internet of Things development, and am still doing minor development on my open-source fitness project, PPL.fitness.

Enter stage right:Nightwatch.js. Super simple to set up. I get to use Node.js to simulate clicks, typing, and key presses, and check to see if elements are visible. I also get to check properties of the elements. Plus, it runs against the industry-standard Selenium server.

Though the initial setup took about a day to get my code decently covered by tests, I can now rest a little easier knowing that when I release new feature updates to my software, everything will work.

//this is where we make our actual comparisons to see if everything is working!
client.expect.element(‘#template-container .headline-1 .splash__header’).text.to.equal(‘Automated Testing Is the Best!’);
client.expect.element(‘#template-container .headline-1 .splash__header’).to.have.css(‘font-size’, ’80px’);
client.expect.element(‘#template-container .headline-1 .splash__header’).to.have.css(‘color’, ‘#2D7061’);

client.end();
}
};
[/code]

As you can see, the syntax is really simple!

[code]

expect(elementSelector).to.have.css(style, value)

expect(elementSelector).text.to.equal(value)

[/code]

I am even able to test the type of my remote data store’s JSON schema with it by running AngularJS commands using client.api.execute(command)!