Skip to content

Commit 2b8ea08

Browse files
DavertMikclaude
andcommitted
fix: use duck-typing for StepConfig detection instead of instanceof
instanceof fails when StepConfig is loaded from different module paths (e.g., symlinked packages). Add __isStepConfig marker and static isStepConfig() method for reliable detection across module boundaries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8b16fe8 commit 2b8ea08

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/els.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { isAsyncFunction, humanizeFunction } from './utils.js'
99

1010
function element(purpose, locator, fn) {
1111
let stepConfig
12-
if (arguments[arguments.length - 1] instanceof StepConfig) {
12+
if (StepConfig.isStepConfig(arguments[arguments.length - 1])) {
1313
stepConfig = arguments[arguments.length - 1]
1414
}
1515

lib/step/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class StepConfig {
1616
timeout: undefined,
1717
retry: undefined,
1818
}
19+
this.__isStepConfig = true
20+
}
21+
22+
static isStepConfig(obj) {
23+
return obj && (obj instanceof StepConfig || obj.__isStepConfig === true)
1924
}
2025

2126
/**

lib/step/record.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function recordStep(step, args) {
1111

1212
// apply step configuration
1313
const lastArg = args[args.length - 1]
14-
if (lastArg instanceof StepConfig) {
14+
if (StepConfig.isStepConfig(lastArg)) {
1515
const stepConfig = args.pop()
1616
const { opts, timeout, retry } = stepConfig.getConfig()
1717

0 commit comments

Comments
 (0)