caolan / caolan/nodeunit

Wrap tests in domain instead of try/catch

オープン
#217 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
1.9k
フォーク
359
PR マージ指標
30日以内にマージされた PR はありません

説明

In several cases, async errors with nodeunit and streams2 only result in the test giving a "test not run or test.done not called". without any sign of the error. What I ended up doing is something like this

``` javascript
Function.prototype.withDomain = function(withStack) {
var fn = this;
return function(test) {
var d = domain.create();
d.on('error', function(e) {
test.fail('test failed with ' + e.message);
if(withStack) {
console.error(e.stack)
}
test.done();
});
d.run(fn.bind(this, test));
}
}

exports['my test'] = function (test) {
setTimeout(function() {
throw new Error('Throwing an error asynchronously');
test.done()
});
}.withDomain()

```

I just thought this was useful enough to be the default.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

The issue provides a Function.prototype.withDomain example and identifies nodeunit tests with streams2 as the affected area. Start by reading nodeunit's asynchronous test execution and error-handling path, then run the existing test suite with an asynchronous stream error. Done means those errors fail the relevant test with a useful message instead of reporting only that test.done was not called.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
testing
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。