LoginSignup
0

More than 5 years have passed since last update.

mocha で co な非同期テストケースを使う

Posted at

coは戻り値としてfunction (done) { ... }みたいな関数("thunk")を返すので、コールバックを受け取る関数だと非同期になるmochaと組み合わせてこのようにシンプルに書けるようだ。
(作者が同じ visionmedia 氏なので、考慮に入れられているっぽい?)

it('should do something', co(function *() {
  ...
  actual = yield doSomething();
  assert.equal(expected, actual);
  ...
}));

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0