1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.params = exports.skip = exports.only = exports.pending = exports.retries = exports.timeout = exports.slow = exports.test = exports.suite = exports.context = void 0;
|
4 | const core = require("@testdeck/core");
|
5 | function applyTimings(fn, settings) {
|
6 | if (settings) {
|
7 | if (fn.length === 1) {
|
8 | return core.wrap(function (done) {
|
9 | if (settings.retries !== undefined) {
|
10 | this.retries(settings.retries);
|
11 | }
|
12 | if (settings.slow !== undefined) {
|
13 | this.slow(settings.slow);
|
14 | }
|
15 | if (settings.timeout !== undefined) {
|
16 | this.timeout(settings.timeout);
|
17 | }
|
18 | return fn.call(this, done);
|
19 | }, fn);
|
20 | }
|
21 | else {
|
22 | return core.wrap(function () {
|
23 | if (settings.retries !== undefined) {
|
24 | this.retries(settings.retries);
|
25 | }
|
26 | if (settings.slow !== undefined) {
|
27 | this.slow(settings.slow);
|
28 | }
|
29 | if (settings.timeout !== undefined) {
|
30 | this.timeout(settings.timeout);
|
31 | }
|
32 | return fn.call(this);
|
33 | }, fn);
|
34 | }
|
35 | }
|
36 | else {
|
37 | return fn;
|
38 | }
|
39 | }
|
40 | const mochaRunner = {
|
41 | suite(name, callback, settings) {
|
42 | switch (settings && settings.execution) {
|
43 | case "only":
|
44 | describe.only(name, applyTimings(callback, settings));
|
45 | break;
|
46 | case "skip":
|
47 | describe.skip(name, applyTimings(callback, settings));
|
48 | break;
|
49 | case "pending":
|
50 |
|
51 | describe.skip(name, applyTimings(callback, settings));
|
52 | break;
|
53 | default:
|
54 | describe(name, applyTimings(callback, settings));
|
55 | }
|
56 | },
|
57 | test(name, callback, settings) {
|
58 | switch (settings && settings.execution) {
|
59 | case "only":
|
60 | it.only(name, applyTimings(callback, settings));
|
61 | break;
|
62 | case "skip":
|
63 | it.skip(name, applyTimings(callback, settings));
|
64 | break;
|
65 | case "pending":
|
66 | it(name);
|
67 | break;
|
68 | default:
|
69 | it(name, applyTimings(callback, settings));
|
70 | }
|
71 | },
|
72 | beforeAll(name, callback, settings) {
|
73 | before(applyTimings(callback, settings));
|
74 | },
|
75 | beforeEach(name, callback, settings) {
|
76 | beforeEach(applyTimings(callback, settings));
|
77 | },
|
78 | afterEach(name, callback, settings) {
|
79 | afterEach(applyTimings(callback, settings));
|
80 | },
|
81 | afterAll(name, callback, settings) {
|
82 | after(applyTimings(callback, settings));
|
83 | }
|
84 | };
|
85 | class MochaClassTestUI extends core.ClassTestUI {
|
86 |
|
87 | constructor(runner = mochaRunner) {
|
88 | super(runner);
|
89 | }
|
90 | }
|
91 | const mochaDecorators = new MochaClassTestUI();
|
92 | exports.context = mochaDecorators.context, exports.suite = mochaDecorators.suite, exports.test = mochaDecorators.test, exports.slow = mochaDecorators.slow, exports.timeout = mochaDecorators.timeout, exports.retries = mochaDecorators.retries, exports.pending = mochaDecorators.pending, exports.only = mochaDecorators.only, exports.skip = mochaDecorators.skip, exports.params = mochaDecorators.params;
|
93 |
|
\ | No newline at end of file |