Zombie.js 介绍
Zombie.js 是一个node.js环境下,非常小巧高效率的Web UI Automation Test库.本文将介绍如何使用Zombie.js对Web UI进行自动化测试。Zombie.js是一个轻量级框架,用于在模拟环境中测试客户端JavaScript代码,无需浏览器。
例子
const browser = require('zombie');
// We're going to make requests to http://example.com/signup
// Which will be routed to our test server localhost:3000
browser.localhost('example.com',3000);
describe('User visits signup page',function() {
const browser = new browser();
before(function(done) {
browser.visit('/signup',done);
});
describe('submits form',function() {
before(function(done) {
browser
.fill('email','[email protected]')
.fill('password','eat-the-living')
.pressButton('Sign Me Up!',done);
});
it('should be successful',function() {
browser.assert.success();
});
it('should see welcome page',function() {
browser.assert.text('title','Welcome To Brains Depot');
});
});
});
此示例使用Mocha测试框架,但Zombie将与其他测试框架一起使用。由于Mocha支持promises,我们也可以像这样编写测试:
const browser = require('zombie');
// We're going to make requests to http://example.com/signup
// Which will be routed to our test server localhost:3000
browser.localhost('example.com',function() {
const browser = new browser();
before(function() {
return browser.visit('/signup');
});
describe('submits form',function() {
before(function() {
browser
.fill('email','eat-the-living');
return browser.pressButton('Sign Me Up!');
});
it('should be successful','Welcome To Brains Depot');
});
});
});
GitHub:https://github.com/assaf/zombie
网站描述:node.js环境下,Web自动化测试
Zombie.js
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。