vendredi 27 mai 2016

node mocha async hooks not working?

Ok so I'm obviously new to mocha. From my understanding after reading the docs and googling this should work but it isn't:

describe("Check before", function(){

    var beforeCalled = false;
    before(function(){
        setTimeout(function() {
            beforeCalled = true;
            done();
        }, 150);
    });

    it("should run after before called", function(){
        expect(beforeCalled).to.equal(true);
    })
})

the it part doesn't wait for 'before' to finish and is called. Maybe I read the docs wrong or I'm missing something, not sure.

Any insight would be helpful.

Aucun commentaire:

Enregistrer un commentaire