UNPKG

skutter

Version:

Skutter: Opinionated BDD Browser based test framework

25 lines (24 loc) 762 B
"use strict"; class MacroWrapperFactory { static wrap(code) { return function (...invocationArgs) { try { let result = code.apply(this, invocationArgs); if (result) { if (result instanceof Promise) { result.catch((error) => { fail(error); invocationArgs[invocationArgs.length - 1](error); }); } } return result; } catch (excp) { fail(excp); invocationArgs[invocationArgs.length - 1](excp); } }; } } exports.MacroWrapperFactory = MacroWrapperFactory;