mocha with nodejs assert hangs/timeouts for assert(false) instead of error

前端 未结 3 1807
醉梦人生
醉梦人生 2021-01-17 20:56

I have this kind of a mocha test:

describe \'sabah\', →
    beforeEach →
        @sabahStrategy = _.filter(@strats, { name: \'sabah2\' })[0]
            .str         


        
3条回答
  •  被撕碎了的回忆
    2021-01-17 21:47

    When I use Highland.js with a super simple test, Mocha catches the failing assert without any problem:

    var _ = require("highland");
    var fs = require("fs");
    var assert = require("assert");
    
    describe("test", function () {
        it("test", function (done) {
            var s = _([1, 2, 3, 4]);
            s.pull(function (err, result) {
                console.log(result);
                assert(false);
                done();
            });
        });
    });
    

    This suggests that the problem in your example is not Mocha, nor Highland.js. If the articleLinkStream object (or articleSream; it seems to change from snippet to snippet) is custom code then maybe that code is buggy and actually swallows exceptions rather than let them move up the stack.

提交回复
热议问题