Discover a powerful and suitable Javascript

系统 3467 0
 

Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome , Safari or Firefox browser.

Discover a powerful and suitable

Javascript Automatic Testing Toolkit

by Daniel Yang

Purpose

Find out the best Javascript testing library for us.

QUnit vs Jasmine

  • support in brower & Node.js
  • testing of DOM manipulation
  • TDD or BDD

BDD or TDD

in Jasemine

expect(5).toEqual(5);

expect(5).not.toEqual(5);

in Qunit

strictEqual(5, 5);

notStrictEqual(5, 5);

But we need something more...

  • how to test in different browers
  • how to test with a AMD loader
  • and how to automatic testing

JsTestDriver + Jasmine

This is the Taobao's solutions in used, but it has some bugs which make people get fighting mad.

Pro

  • testing in different browers
  • automatic testing
  • BDD style script

Con

  • asynchronous support is not good, and you shall mock up the data when using AJAX.
  • couldn't support all Jasmine method
  • and it built in Java(not JS)

Is there any libaray
can solve these problems?

My answer is Buster.js

Easy to deploy

use npm to install & manager

npm install -g buster

npm install buster-amd

Browser Testing

Buster.JS can automate browsers, JsTestDriver style.

buster server

Buster.JS also has a static browser runner that runs tests by opening a web page in a browser. This is similar to QUnit, Mocha, etc.

buster static

AJAX Testing

using Sinon.JS to mock out the entire XHR stack in a browser, so we can test AJAX easily.

Asynchronous tests

To tag a test as async, have the test function take one argument, done.

The done argument is a function. Call it to tell Buster.JS that the asynchronous test has finished running.

Test reporters

Buster.JS can create all human-consumable reports(by Terminal, JSON, XML and HTML).

Buster Test Reporters Doc

Buster.JS is still beta, so it has some rough edges.

But I think this solutions will satisfy our needs.

Thanks for your watching!

 

Discover a powerful and suitable Javascript Automatic Testing Toolkit


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论