Skip to content

Commit d9af19d

Browse files
author
DavertMik
committed
fixed typings
1 parent 7703147 commit d9af19d

File tree

6 files changed

+43
-10
lines changed

6 files changed

+43
-10
lines changed

lib/step.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
// refactored step class, moved to helper
2+
/**
3+
* Step is wrapper around a helper method.
4+
* It is used to create a new step that is a combination of other steps.
5+
*/
6+
const BaseStep = require('./step/base')
7+
const StepConfig = require('./step/config')
28
const Step = require('./step/helper')
9+
10+
/**
11+
* MetaStep is a step that is used to wrap other steps.
12+
* It is used to create a new step that is a combination of other steps.
13+
* It is used to create a new step that is a combination of other steps.
14+
*/
315
const MetaStep = require('./step/meta')
416

517
module.exports = Step
618
module.exports.MetaStep = MetaStep
19+
module.exports.BaseStep = BaseStep
20+
module.exports.StepConfig = StepConfig

lib/step/base.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const STACK_LINE = 4
88
/**
99
* Each command in test executed through `I.` object is wrapped in Step.
1010
* Step allows logging executed commands and triggers hook before and after step execution.
11-
* @param {CodeceptJS.Helper} helper
1211
* @param {string} name
1312
*/
1413
class Step {
@@ -21,7 +20,7 @@ class Step {
2120
/** @member {Array<*>} */
2221
this.args = []
2322

24-
/** @member {StepConfig} */
23+
/** @member {Record<string,any>} */
2524
this.opts = {}
2625
/** @member {string} */
2726
this.actor = 'I' // I = actor
@@ -33,7 +32,7 @@ class Step {
3332
this.prefix = this.suffix = ''
3433
/** @member {string} */
3534
this.comment = ''
36-
/** @member {MetaStep} */
35+
/** @member {import('./meta')} */
3736
this.metaStep = undefined
3837
/** @member {string} */
3938
this.stack = ''

lib/step/config.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
1+
/**
2+
* StepConfig is a configuration object for a step.
3+
* It is used to create a new step that is a combination of other steps.
4+
*/
15
class StepConfig {
2-
constructor(opts) {
6+
constructor(opts = {}) {
7+
/** @member {{ opts: Record<string, any>, timeout: number|undefined, retry: number|undefined }} */
38
this.config = {
49
opts,
510
timeout: undefined,
611
retry: undefined,
712
}
813
}
914

15+
/**
16+
* Set the options for the step.
17+
* @param {object} opts - The options for the step.
18+
* @returns {StepConfig} - The step configuration object.
19+
*/
1020
opts(opts) {
1121
this.config.opts = opts
1222
return this
1323
}
1424

25+
/**
26+
* Set the timeout for the step.
27+
* @param {number} timeout - The timeout for the step.
28+
* @returns {StepConfig} - The step configuration object.
29+
*/
1530
timeout(timeout) {
1631
this.config.timeout = timeout
1732
return this
1833
}
1934

35+
/**
36+
* Set the retry for the step.
37+
* @param {number} retry - The retry for the step.
38+
* @returns {StepConfig} - The step configuration object.
39+
*/
2040
retry(retry) {
2141
this.config.retry = retry
2242
return this

lib/step/meta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const event = require('../event')
33
const { humanizeString } = require('../utils')
44

55
class MetaStep extends Step {
6-
constructor(obj, method) {
6+
constructor(actor, method) {
77
if (!method) method = ''
88
super(method)
9-
this.actor = obj
9+
this.actor = actor
1010
}
1111

1212
/** @return {boolean} */

typings/index.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,6 @@ declare namespace CodeceptJS {
451451
}
452452

453453
// Extending JSDoc generated typings
454-
interface Step {
455-
isMetaStep(): this is MetaStep
456-
}
457454

458455
// Types who are not be defined by JSDoc
459456
type actor = <T extends { [action: string]: (...args: any[]) => void }>(customSteps?: T & ThisType<WithTranslation<Methods & T>>) => WithTranslation<Methods & T>

typings/jsdoc.conf.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ module.exports = {
1616
'./lib/recorder.js',
1717
'./lib/secret.js',
1818
'./lib/session.js',
19-
'./lib/step.js',
19+
'./lib/step/config.js',
20+
'./lib/step/base.js',
21+
'./lib/step/helper.js',
22+
'./lib/step/meta.js',
2023
'./lib/store.js',
2124
'./lib/mocha/ui.js',
2225
'./lib/mocha/featureConfig.js',

0 commit comments

Comments
 (0)