我可以知道Zombie.js和Jasmine有什么区别吗?它们都是框架吗?
发布于 2017-02-06 14:58:11
是一个用于行为驱动开发的单元测试框架。它需要像NodeJs这样的执行环境或火狐、Chrome、IE、PhantomJS等浏览器才能运行(并为测试代码提供环境)。Jasmine提供测试执行和断言基础设施(即describe()、it()、expect())。
是一个模拟的、无头浏览器。它是一个独立的浏览器,外加一个自己的交互API。它就像Selenium/Webdriver。它在幕后使用jsdom来提供浏览器通常提供的API。Zombie.js需要测试执行和断言基础设施(如Mocha + should.js甚至Jasmine)。
使用
Jasmine,您只测试Javascript部分。
Jasmine示例:
// spy on other module to know "method" was called on it
spyOn(otherModule, "method");
// create module
let module = new Module(otherModule),
returnValue;
// calls otherModule.method() with the passed value too; always returns 42
returnValue = module(31415);
// assert result and interaction with other modules
expect(returnValue).toBe(42);
expect(otherModule.method).toHaveBeenCalledWith(31415);Zombie.js示例:
// create browser
const browser = new Browser();
// load page by url
browser.visit('/signup', function() {
browser
// enter form data by name/CSS selectors
.fill('email', 'zombie@underworld.dead')
.fill('password', 'eat-the-living')
// interact, press a button
.pressButton('Sign Me Up!', done);
});
// actual test for output data
browser.assert.text('title', 'Welcome To Brains Depot');Zombie.js,就像Webdriver/Selenium一样,不能替代像Jasmine,Mocha这样的单元测试框架。
https://stackoverflow.com/questions/42044444
复制相似问题