Skip to content

Commit 40434aa

Browse files
author
DavertMik
committed
fixed type definitions
1 parent fd497a9 commit 40434aa

File tree

3 files changed

+67
-55
lines changed

3 files changed

+67
-55
lines changed

lib/listener/steps.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
1-
const debug = require('debug')('codeceptjs:steps');
2-
const event = require('../event');
3-
const store = require('../store');
4-
const output = require('../output');
5-
const { BeforeHook, AfterHook, BeforeSuiteHook, AfterSuiteHook } = require('../mocha/hooks');
1+
const debug = require('debug')('codeceptjs:steps')
2+
const event = require('../event')
3+
const store = require('../store')
4+
const output = require('../output')
5+
const { BeforeHook, AfterHook, BeforeSuiteHook, AfterSuiteHook } = require('../mocha/hooks')
66

7-
let currentTest;
8-
let currentHook;
7+
let currentTest
8+
let currentHook
99

1010
/**
1111
* Register steps inside tests
1212
*/
1313
module.exports = function () {
1414
event.dispatcher.on(event.test.before, test => {
15-
test.startedAt = +new Date();
16-
test.artifacts = {};
17-
});
15+
test.startedAt = +new Date()
16+
test.artifacts = {}
17+
})
1818

1919
event.dispatcher.on(event.test.started, test => {
20-
currentTest = test;
21-
currentTest.steps = [];
22-
if (!('retryNum' in currentTest)) currentTest.retryNum = 0;
23-
else currentTest.retryNum += 1;
24-
output.scenario.started(test);
25-
});
20+
currentTest = test
21+
currentTest.steps = []
22+
if (!('retryNum' in currentTest)) currentTest.retryNum = 0
23+
else currentTest.retryNum += 1
24+
output.scenario.started(test)
25+
})
2626

2727
event.dispatcher.on(event.test.after, test => {
28-
currentTest = null;
29-
});
28+
currentTest = null
29+
})
3030

31-
event.dispatcher.on(event.test.finished, test => {});
31+
event.dispatcher.on(event.test.finished, test => {})
3232

3333
event.dispatcher.on(event.hook.started, hook => {
34-
currentHook = hook.ctx.test;
35-
currentHook.steps = [];
34+
currentHook = hook.ctx.test
35+
currentHook.steps = []
3636

37-
output.hook.started(hook);
37+
output.hook.started(hook)
3838

39-
if (hook.ctx && hook.ctx.test) output.log(`--- STARTED ${hook.ctx.test.title} ---`);
40-
});
39+
if (hook.ctx && hook.ctx.test) debug(`--- STARTED ${hook.ctx.test.title} ---`)
40+
})
4141

4242
event.dispatcher.on(event.hook.passed, hook => {
43-
currentHook = null;
44-
output.hook.passed(hook);
45-
if (hook.ctx && hook.ctx.test) output.log(`--- ENDED ${hook.ctx.test.title} ---`);
46-
});
43+
currentHook = null
44+
output.hook.passed(hook)
45+
if (hook.ctx && hook.ctx.test) debug(`--- ENDED ${hook.ctx.test.title} ---`)
46+
})
4747

4848
event.dispatcher.on(event.test.failed, () => {
4949
const cutSteps = function (current) {
50-
const failureIndex = current.steps.findIndex(el => el.status === 'failed');
50+
const failureIndex = current.steps.findIndex(el => el.status === 'failed')
5151
// To be sure that failed test will be failed in report
52-
current.state = 'failed';
53-
current.steps.length = failureIndex + 1;
54-
return current;
55-
};
52+
current.state = 'failed'
53+
current.steps.length = failureIndex + 1
54+
return current
55+
}
5656
if (currentHook && Array.isArray(currentHook.steps) && currentHook.steps.length) {
57-
currentHook = cutSteps(currentHook);
58-
return (currentHook = null);
57+
currentHook = cutSteps(currentHook)
58+
return (currentHook = null)
5959
}
60-
if (!currentTest) return;
60+
if (!currentTest) return
6161
// last step is failing step
62-
if (!currentTest.steps.length) return;
63-
return (currentTest = cutSteps(currentTest));
64-
});
62+
if (!currentTest.steps.length) return
63+
return (currentTest = cutSteps(currentTest))
64+
})
6565

6666
event.dispatcher.on(event.test.passed, () => {
67-
if (!currentTest) return;
67+
if (!currentTest) return
6868
// To be sure that passed test will be passed in report
69-
delete currentTest.err;
70-
currentTest.state = 'passed';
71-
});
69+
delete currentTest.err
70+
currentTest.state = 'passed'
71+
})
7272

7373
event.dispatcher.on(event.step.started, step => {
74-
step.startedAt = +new Date();
75-
step.test = currentTest;
74+
step.startedAt = +new Date()
75+
step.test = currentTest
7676
if (currentHook && Array.isArray(currentHook.steps)) {
77-
return currentHook.steps.push(step);
77+
return currentHook.steps.push(step)
7878
}
79-
if (!currentTest || !currentTest.steps) return;
80-
currentTest.steps.push(step);
81-
});
79+
if (!currentTest || !currentTest.steps) return
80+
currentTest.steps.push(step)
81+
})
8282

8383
event.dispatcher.on(event.step.finished, step => {
84-
step.finishedAt = +new Date();
85-
if (step.startedAt) step.duration = step.finishedAt - step.startedAt;
86-
debug(`Step '${step}' finished; Duration: ${step.duration || 0}ms`);
87-
});
88-
};
84+
step.finishedAt = +new Date()
85+
if (step.startedAt) step.duration = step.finishedAt - step.startedAt
86+
debug(`Step '${step}' finished; Duration: ${step.duration || 0}ms`)
87+
})
88+
}

lib/mocha/featureConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class FeatureConfig {
3131
/**
3232
* Configures a helper.
3333
* Helper name can be omitted and values will be applied to first helper.
34+
*
35+
* @param {string|number} helper
36+
* @param {*} obj
37+
* @returns {this}
3438
*/
3539
config(helper, obj) {
3640
if (!obj) {

lib/mocha/scenarioConfig.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ScenarioConfig {
1212
* Can pass an Error object or regex matching expected message.
1313
*
1414
* @param {*} err
15+
* @returns {this}
1516
*/
1617
throws(err) {
1718
this.test.throws = err
@@ -23,7 +24,7 @@ class ScenarioConfig {
2324
* If test passes - throws an error.
2425
* Can pass an Error object or regex matching expected message.
2526
*
26-
* @param {*} err
27+
* @returns {this}
2728
*/
2829
fails() {
2930
this.test.throws = new Error()
@@ -34,6 +35,7 @@ class ScenarioConfig {
3435
* Retry this test for number of times
3536
*
3637
* @param {number} retries
38+
* @returns {this}
3739
*/
3840
retry(retries) {
3941
this.test.retries(retries)
@@ -43,6 +45,7 @@ class ScenarioConfig {
4345
/**
4446
* Set timeout for this test
4547
* @param {number} timeout
48+
* @returns {this}
4649
*/
4750
timeout(timeout) {
4851
this.test.timeout(timeout)
@@ -52,6 +55,7 @@ class ScenarioConfig {
5255
/**
5356
* Pass in additional objects to inject into test
5457
* @param {*} obj
58+
* @returns {this}
5559
*/
5660
inject(obj) {
5761
this.test.inject = obj
@@ -61,6 +65,9 @@ class ScenarioConfig {
6165
/**
6266
* Configures a helper.
6367
* Helper name can be omitted and values will be applied to first helper.
68+
* @param {string|number} helper
69+
* @param {*} obj
70+
* @returns {this}
6471
*/
6572
config(helper, obj) {
6673
if (!obj) {
@@ -80,6 +87,7 @@ class ScenarioConfig {
8087
/**
8188
* Append a tag name to scenario title
8289
* @param {string} tagName
90+
* @returns {this}
8391
*/
8492
tag(tagName) {
8593
if (tagName[0] !== '@') tagName = `@${tagName}`

0 commit comments

Comments
 (0)