A simple function function add(a, b) { return a + b; } Higher-order functions function makeAdder(base) { return function (num) { return base + num; }; }
For a while now, August Lilleaas and myself have been working on Buster.JS, a new test framework for JavaScript. Because the JavaScript community is already plagued with piles and piles of half-baked test frameworks, we've kept ours away from general consumption until we feel that it provides actual progress. To reduce the wait, I will show you how you can use the assertions and some related tools
Date#strftime var date = new Date(2011, 5, 29); date.strftime("%Y-%m-%d"); "2011-06-29" Problems ahead var date = new Date(2009, 11, 5); date.strftime("%Y"); //=> "2009" date.strftime("%m"); //=> "12" date.strftime("%d"); //=> "05" date.strftime("%y"); //=> "9" Test setup <!DOCTYPE html> <html> <head> <title>Date.prototype.strftime test</title> </head> <body> <script type="text/javascript" src="st
In addition to low-level tools for stubbing and mocking and high-level tools to integrate with test runners, Sinon provides a few useful utilities. This post explains the first of these, which is fake timers and Dates. Testing time Client-side JavaScript frequently utilizes setTimeout, clearTimeout, setInterval and clearInterval to defer execution. When testing code that depends on these functions
Since my talk at Front-Trends in Poland last week I've gotten a few requests for examples of using Sinon.JS with QUnit. Sinon.JS is completely test framework agnostic and should be very easy to use with any testing framework. This post introduces a mini-plugin, sinon-qunit and shows a few examples of using Sinon.JS with QUnit. Spies, stubs and mocks Using one-off spies, stubs and mocks is straight
Example is a modified test from Morgan Roderick's PubSubJS. "test should call subscriber": function () { var spy = sinon.spy(); PubSub.subscribe("message", spy); PubSub.publishSync("message", undefined); assertTrue(spy.called); } Example is a modified test from Morgan Roderick's PubSubJS. "test should call all subscribers when exceptions": function () { var spy = sinon.spy(); var stub = sinon.stub
In a series of three articles I am going to walk you through the what's and why's of unit testing and test driven development focusing on JavaScript. We'll look into the underlying concepts, available frameworks for JavaScript, and of course a practical example to top it all off. The following is an introduction to the basic concepts. It is by no means exhaustive, but you'll find links to more res
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く