浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
Insanely fast, headless full-stack testing using Node.js
Zombie.js
Insanely fast, headless full-stack testing using Node.js
The Bite

If you're going to write an insanely fast, headless browser, how can you not call it Zombie? Zombie it is.

Zombie.js is a lightweight framework for testing client-side JavaScript code in a simulated environment. No browser required.

Let's try to sign up to a page and see what happens:

var zombie = require("zombie");
var assert = require("assert");

// Load the page from localhost
zombie.visit("http://localhost:3000/", function (err, browser, status) {

// Fill email, password and submit form
browser.
fill("email", "zombie@underworld.dead").
fill("password", "eat-the-living").
pressButton("Sign Me Up!", function(err, browser, status) {

// Form submitted, new page loaded.
assert.equal(browser.text("title"), "Welcome To Brains Depot");

})

});

Well, that was easy.


posted on 2011-10-26 13:02  lexus  阅读(503)  评论(0编辑  收藏  举报