Skip to content

Commit 99d93f9

Browse files
author
DavertMik
committed
initial implementation for step params
1 parent 6edc423 commit 99d93f9

File tree

6 files changed

+38
-1
lines changed

6 files changed

+38
-1
lines changed

lib/effects.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { StepConfig } = require('./step')
2+
3+
function stepConfig(opts) {
4+
return new StepConfig(opts)
5+
}
6+
7+
module.exports = {
8+
stepConfig,
9+
}

lib/helper/Playwright.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3499,6 +3499,12 @@ async function proceedSee(assertType, text, context, strict = false) {
34993499
allText = await Promise.all(els.map(el => el.innerText()))
35003500
}
35013501

3502+
if (store?.currentStep?.opts?.ignoreCase === true) {
3503+
description = description.toLowerCase()
3504+
text = text.toLowerCase()
3505+
allText = allText.map(elText => elText.toLowerCase())
3506+
}
3507+
35023508
if (strict) {
35033509
return allText.map(elText => equals(description)[assertType](text, elText))
35043510
}

lib/listener/steps.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ module.exports = function () {
7373
event.dispatcher.on(event.step.started, step => {
7474
step.startedAt = +new Date()
7575
step.test = currentTest
76+
store.currentStep = step
7677
if (currentHook && Array.isArray(currentHook.steps)) {
7778
return currentHook.steps.push(step)
7879
}
@@ -84,5 +85,7 @@ module.exports = function () {
8485
step.finishedAt = +new Date()
8586
if (step.startedAt) step.duration = step.finishedAt - step.startedAt
8687
debug(`Step '${step}' finished; Duration: ${step.duration || 0}ms`)
88+
store.currentStep = null
89+
store.stepOptions = null
8790
})
8891
}

lib/step.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class Step {
6161
this.metaStep = undefined
6262
/** @member {string} */
6363
this.stack = ''
64+
/** @member {StepConfig} */
65+
this.opts = {}
6466

6567
const timeouts = new Map()
6668
/**
@@ -114,6 +116,13 @@ class Step {
114116
*/
115117
run() {
116118
this.args = Array.prototype.slice.call(arguments)
119+
const lastArg = this.args[this.args.length - 1]
120+
if (lastArg instanceof StepConfig) {
121+
const config = this.args.pop()
122+
store.stepOptions = config.options
123+
this.opts = config.options
124+
}
125+
117126
if (store.dryRun) {
118127
this.setStatus('success')
119128
return Promise.resolve(new Proxy({}, dryRunResolver()))
@@ -321,10 +330,17 @@ class MetaStep extends Step {
321330
}
322331
}
323332

333+
class StepConfig {
334+
constructor(opts) {
335+
this.options = opts
336+
}
337+
}
338+
324339
Step.TIMEOUTS = {}
325340

326341
/** @type {Class<MetaStep>} */
327342
Step.MetaStep = MetaStep
343+
Step.StepConfig = StepConfig
328344

329345
module.exports = Step
330346

lib/store.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const store = {
1313
onPause: false,
1414
/** @type {CodeceptJS.Test | null} */
1515
currentTest: null,
16+
/** @type {any} */
17+
currentStep: null,
1618
}
1719

1820
module.exports = store

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"main": "lib/index.js",
3232
"exports": {
3333
".": "./lib/index.js",
34-
"./els": "./lib/els.js"
34+
"./els": "./lib/els.js",
35+
"./effects": "./lib/effects.js"
3536
},
3637
"types": "typings/index.d.ts",
3738
"bin": {

0 commit comments

Comments
 (0)