Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 2x 2x 2x 240x 240x 240x 240x 240x 240x 239x 239x 239x 239x 2x | "use strict"; const _ = require("lodash"); const U = require("glace-utils"); /** * Execute tests scope. * * @global * @function * @arg {string} name - Scope name. * @arg {function[]} [fixtures] - List of fixtures. * @arg {object} [opts] - Scope options. * @arg {number} [opts.chunkRetry] - Number of chunk retries on failure. * @arg {number} [opts.chunkTimeout] - Time to execute chunk or hook, sec. * @arg {function} func - Callback function with test cases. * @example scope("Some test scope", () => { test("Some test name", () => { before(() => { someFunc(); }); chunk("chunk #1", () => { someFunc(); }); chunk("chunk #2", () => { someFunc(); }); }); }); */ const scope = (name, fixtures, opts, func) => { if (_.isFunction(opts)) [func, opts] = [opts]; if (_.isPlainObject(fixtures)) [opts, fixtures] = [fixtures]; if (_.isFunction(fixtures)) [func, fixtures] = [fixtures]; fixtures = fixtures || []; opts = opts || {}; describe(name, scopeCb(fixtures, opts, func)); }; /** * Scope callback. * @ignore */ const scopeCb = (fixtures, opts, func) => function () { if (opts.chunkRetry) this.retries(opts.chunkRetry); if (opts.chunkTimeout) this.timeout(opts.chunkTimeout * 1000); U.wrap(fixtures, func)(); }; module.exports = scope; |