ciscoheat/buddy

Run next class only when async tests are done?

kevinresol opened this issue · 6 comments

Is it possible to run next test class only when all the async tests of current class are finished?

Only one test class is run at a time, so if you're using the done callback for async tests, isn't that the behavior?

oh, just double checked the behaviour. I think I am looking for a beforeAll/afterAll feature.

Because currently the code inside describe is run immediately for all classes without waiting for any async tests. (at first I thought it will be run only when the test class is run, so I misunderstood that all test class are run immediately)

current workaround is:

describe("AsyncTest", {
    var inited = false;

    before({
        if(inited) return;
        inited = true;
        // init code here....
    });    

    // it(...);
});

I'm the rewrite, very soon completed, you will be able to use beforeAll/afterAll!

describe("AsyncTest", {
    beforeAll({
        // init code here, only executed once per describe.
    });

    beforeEach({
        // Executed before every it and nested describe
    });

    it(...);

    afterEach(...);
    afterAll(...);
});

I'll let you know as soon as it's available.

Version 1.0.0 has been released! Please check it out and see if it works as you expect. :)

I think this works now. Thanks!