metarhia / metatests

Extremely simple to use test framework and runner for Metarhia technology stack 🧪
https://metarhia.com
Other
18 stars 4 forks source link

Allow to pass afterAll callback to cbFail #151

Closed lundibundi closed 5 years ago

lundibundi commented 5 years ago

This will allow to also use this function when additional callback needs to be called. (e.g. from test.beforeEach or test.afterEach).

e.g.

test('test', test => {
  test.beforeEach((t, cb) => {
    metasync.sequential([
      (ctx, cb) => method1('a', t.cbFail(data => ctx.a = data, cb)),
      (ctx, cb) => method2('b', t.cbFail(data => ctx.b = data, cb)),
    ], cb);
  });

  test.beforeEach((t, cb) => {
    method('a', t.cbFail(data => console.log(data), () => cb()));
  });
});
lundibundi commented 5 years ago

That's true, this solution is quite crude but at least it allows to properly use the cbFail function in cases when additional callback needs to be called. I'll be happy to change this to something better.

lundibundi commented 5 years ago

Landed in https://github.com/metarhia/metatests/commit/d5fbe7827bd388d9d78c2bb7f98cd02b83331562.