Fast-failing zombie test
When I outside-in tdd my last web feature, I find the following useful to have zombie failing with a helpful error message when unable to find an element in a page.
Here is an example of this in the prime-factors kata. The tip is in the fail().
Browser = require("zombie");
describe("decomposition", function() {
var home = "http://localhost:5000/index.html";
var browser = new Browser();
it("displays the decomposition of the input number", function(done) {
browser.visit(home).
then(function () {
browser.fill("#number", "42")
.clickLink("#decompose");
}).
then(function() {
expect(browser.text("#decomposition")).toEqual("42 = 2 x 3 x 7");
done();
}).
fail(function(error) {
expect(error.toString()).toBeNull();
done();
});
});
});Written by Eric
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#