You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
BDD The BDD styles are expect and should. Both use the same chainable language to construct assertions, but they differ in the way an assertion is initially constructed. Check out the Style Guide for a comparison. API Reference Language Chains The following are provided as chainable getters to improve the readability of your assertions. Chains to be been is that which and has have with at of same
Assert The assert style is very similar to node.js’ included assert module, with a bit of extra sugar. Of the three style options, assert is the only one that is not chainable. Check out the Style Guide for a comparison. API Reference assert(expression, message) @param { Mixed } expression to test for truthiness @param { String } message to display on error Write your own test expressions. assert(
Assertion Styles This section of the guide introduces you to the three different assertion styles that you may use in your testing environment. Once you have made your selection, it is recommended that you look at the API Documentation for your selected style. Assert View full Assert API The assert style is exposed through assert interface. This provides the classic assert-dot notation, similar to
API Reference The Chai API is broken down by style or task. Assertion Styles The Expect / Should API covers the BDD assertion styles. The Assert API covers the TDD assertion style. Plugins The Plugin API will be of use to anyone interested in building plugins as helpers to DRY up your tests, or for release to the community. Tools The Online Test Suite is a live run of Chai’s test suite. Use it to
Chai Assertions for Promises Chai as Promised extends Chai with a fluent language for asserting facts about promises. Instead of manually wiring up your expectations to a promise’s fulfilled and rejected handlers: doSomethingAsync().then( function (result) { result.should.equal("foo"); done(); }, function (err) { done(err); } );
chai-jquery chai-jquery is an extension to the chai assertion library that provides a set of jQuery-specific assertions. Usage Include chai-jquery.js in your test file, after jquery.js and chai.js (version 1.0.0-rc1 or later): <script src="jquery.js"></script> <script src="chai.js"></script> <script src="chai-jquery.js"></script> Note that jquery.js and chai.js can be inserted one before another (
chai-json-schema Chai plugin with assertions to validate values against JSON Schema v4. Assert both simple values and complex objects with the rich collection of validation terms (examples). For general help with json-schema see this excellent guide and usable reference. Notes JSON Schema validation is done by Tiny Validator tv4. It seems that tv4 is not actively developed anymore, nor does it sup
Unit testing framework for Javascript Unit.js is an assertion library for Javascript, running on Node.js and the browser. It works with any test runner and unit testing framework like Mocha, Jasmine, Karma, protractor (E2E test framework for Angular apps), QUnit, ... and more. Unit.js supports dependency injection and is extensible via a plugins system easy to use.
Mocha Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases. Mocha is free and open source, licensed under the MIT license. If you want to learn more on Mocha, see official Mocha documentat
Should.js API documentation Should.js is included in Unit.JS, you can use Should.js with Unit.js : var test = require('unit.js'); // test 'string' type test.should('foobar').be.type('string'); // then that actual value '==' expected value test.should('foobar' == 'foobar').be.ok; // then that actual value '===' expected value test.should('foobar').be.equal('foobar'); // Should.js library (alternati
describe("Asynchronous specs", function() { var value, flag; it("should support async execution of test preparation and exepectations", function() { runs(function() { flag = false; value = 0; setTimeout(function() { flag = true; }, 500); }); waitsFor(function() { value++; return flag; }, "The Value should be incremented", 750); runs(function() { expect(value).toBeGreaterThan(0); }); }); });
AngularJSを利用したのなら、絶対にKarmaとか Protractorを活用すべきです。ちゅうか、活用しなさい。と言いたいです。システムを保守フェーズに安定的にメンテナンスするならそう考えるのがふつうになるべき。 (※Protractorについては、こちらの記事がとても参考になります) 例によって「Mastering web application development with AngularJS」を読んで書かれていたポイントを読んだ感想をこちらにまとめてますが、 2章のテスト解説部分に下記の文章があります。 There is a quote saying that writing code without a Version Control system (VCS) is like skydiving without a parachute. Today one would
I was hoping to get an error message that might lead me a step forward, but it looks like the compilers option was simply ignored. Next attempt: Imitate the Coffeescript compiler, because it looks like that is working nicely for other people. Since the command for compiling Coffeescript is mocha --compilers coffee:coffee-script/register, I took a look at this crazy require patcher thing. It looks
[追記] 2013/9/1 三年前の記事が未だに読まれているようなので、一応書いておきますが、あれから色々変わってもっと良いものも出ています。 QUnit でも別に問題はないですが、今から QUnit を使うよりは http://visionmedia.github.io/mocha/:title=mocha] とかの方が個人的にはお勧めです。とにかく、今は色々あるのでもっと別の選択肢調べて見ることを個人的にはおすすめします。別に QUnit は使わないほうが良いとは言いません。 JavaScriptのテスティングフレームワークはいろいろありますが、自分は今主にQUnitを使っているので、少し使い方をまとめて見たいと思います。 [追記]今回作成したソースを上げました。ninja.js QUnit とは QUnitはもともと、jQueryをテストするために開発されたJavaScript Un
The powerful, easy-to-use JavaScript testing framework.Get Started View the Docs Easy Zero configuration and setup for any Node.js project, and minimal setup for Browser-based projects. Universal QUnit can run anywhere; web browsers, Node, SpiderMonkey, even in a Web Worker! Test your code where it runs.
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く