cocha

Run mocha with generators + co

Usage no npm install needed!

<script type="module">
  import cocha from 'https://cdn.skypack.dev/cocha';
</script>

README

Cocha

Ripped shamelessly from https://labnotes.org/yield-to-the-test-using-mocha-with-es6-generators/

first install with

npm install cocha
npm install mocha

then you can test co friendly mocha code:

var thunkify = require('thunkify');
var assert = require('assert');
var fs = require('fs');

describe('cocha', function(){

  it('should work when async', function *(){
    function read(file, fn) {
      setTimeout(function(){
        fn(null, 'file: ' + file);
      }, 5);
    }

    read = thunkify(read);

    var res = yield read('foo.txt');
    assert('file: foo.txt' == res);
  })

})

testing: npm test