Skip to content

Commit 0ea4b3f

Browse files
committed
Eslint fix
1 parent 93a2922 commit 0ea4b3f

File tree

7 files changed

+42
-30
lines changed

7 files changed

+42
-30
lines changed

packages/app/src/controller/DataManager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ export class DataManagerController implements ReactiveController {
9191
// If we are already tracking a feature-level rerun and this clear is for
9292
// a child scenario (not the top-level rerun trigger itself), skip resetting
9393
// execution data so previously-completed scenarios' data is preserved.
94-
const isChildOfActiveRerun = !!(uid && rerunState.activeRerunSuiteUid && uid !== rerunState.activeRerunSuiteUid)
94+
const isChildOfActiveRerun = !!(
95+
uid &&
96+
rerunState.activeRerunSuiteUid &&
97+
uid !== rerunState.activeRerunSuiteUid
98+
)
9599

96100
if (!isChildOfActiveRerun) {
97101
this.#resetExecutionData()

packages/nightwatch-devtools/example/tests/login.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
describe('The Internet Guinea Pig Website', function () {
2+
afterEach(async function (browser) {
3+
await browser.end()
4+
})
5+
26
it('should log into the secure area with valid credentials', async function (browser) {
37
console.log('[TEST] Navigating to login page')
4-
browser
8+
await browser
59
.url('https://the-internet.herokuapp.com/login')
610
.waitForElementVisible('body')
711

@@ -15,7 +19,7 @@ describe('The Internet Guinea Pig Website', function () {
1519
'[TEST] Verifying flash message: You logged into a secure area!'
1620
)
1721
await browser
18-
.waitForElementVisible('#flash')
22+
.waitForElementVisible('#flash', 10000)
1923
.assert.textContains('#flash', 'You logged into a secure area!')
2024

2125
console.log('[TEST] Flash message verified successfully')
@@ -35,8 +39,8 @@ describe('The Internet Guinea Pig Website', function () {
3539

3640
console.log('[TEST] Verifying flash message: Your username is invalid!')
3741
await browser
38-
.waitForElementVisible('.flash', 5000)
39-
.assert.textContains('.flash', 'Your username is invalid!')
42+
.waitForElementVisible('#flash', 10000)
43+
.assert.textContains('#flash', 'Your username is invalid!')
4044

4145
console.log('[TEST] Flash message verified successfully')
4246
})

packages/nightwatch-devtools/src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export const NAVIGATION_COMMANDS = ['url', 'navigate', 'navigateTo'] as const
9393
export const SPINNER_RE = /^[]/u
9494

9595
/** Matches a path segment that indicates a test/spec directory (e.g. /tests/, /spec/, /nightwatch/examples/, /features/). */
96-
export const TEST_PATH_PATTERN = /\/(test|spec|tests|nightwatch|examples?|features|step-definitions)\//i
96+
export const TEST_PATH_PATTERN =
97+
/\/(test|spec|tests|nightwatch|examples?|features|step-definitions)\//i
9798

9899
/** Matches file names that follow the *.test.ts / *.spec.js naming convention. */
99100
export const TEST_FILE_PATTERN = /\.(?:test|spec)\.[cm]?[jt]sx?$/i

packages/nightwatch-devtools/src/helpers/browserProxy.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,17 @@ export class BrowserProxy {
9696
result.perform((done: Function) => {
9797
injectAndCapture().finally(() => done && done())
9898
})
99-
} else {
100-
// Cucumber async/await: result is a Promise (or thenable).
101-
Promise.resolve(result)
102-
.then(injectAndCapture)
103-
.catch(() => {})
99+
return result
104100
}
105-
106-
return result
101+
// Cucumber async/await: result is a Promise (or thenable).
102+
// Return the AUGMENTED promise so that `await browser.url(...)` in
103+
// the step definition waits for injectAndCapture to finish before
104+
// Cucumber moves to the next step. Without this the injection races
105+
// with the next step's commands (e.g. setValue), causing stale-element
106+
// errors because the script-tag insertion mutates the DOM mid-form.
107+
return Promise.resolve(result)
108+
.then(injectAndCapture)
109+
.catch(() => {})
107110
}
108111
}
109112

packages/nightwatch-devtools/src/helpers/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ export function extractTestMetadata(filePath: string): TestFileMetadata {
151151
}
152152
}
153153
// describe/it style: it('name', ...) / test('name', ...) / specify('name', ...)
154-
const itMatch = line.match(/(?:it|test|specify)\s*\(\s*['"`]([^'"`]+)['"`]/)
154+
const itMatch = line.match(
155+
/(?:it|test|specify)\s*\(\s*['"`]([^'"`]+)['"`]/
156+
)
155157
if (itMatch) {
156158
result.testNames.push(itMatch[1])
157159
result.testLines.push(lineNum)

packages/nightwatch-devtools/src/index.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ import {
3333
findFreePort,
3434
resolveNightwatchConfig
3535
} from './helpers/utils.js'
36-
import {
37-
DEFAULTS,
38-
TIMING,
39-
TEST_STATE,
40-
CONFIG_FILENAMES,
41-
PLUGIN_GLOBAL_KEY
42-
} from './constants.js'
36+
import { DEFAULTS, TIMING, TEST_STATE, PLUGIN_GLOBAL_KEY } from './constants.js'
4337

4438
const log = logger('@wdio/nightwatch-devtools')
4539

@@ -607,20 +601,22 @@ class NightwatchDevToolsPlugin {
607601
path.join(workspaceRoot, sf, modulePath + '.js'),
608602
path.join(workspaceRoot, sf, modulePath + '.ts'),
609603
path.join(workspaceRoot, sf, modulePath + '.cjs'),
610-
path.join(workspaceRoot, sf, modulePath),
604+
path.join(workspaceRoot, sf, modulePath)
611605
]
612606
: []
613607
)
614608
const possiblePaths = [
615609
// Highest priority: expand module path via each configured src_folder
616610
...srcFolderPaths,
617611
// Fallback: treat module path as relative to cwd (works when src_folders isn't nested)
618-
...(modulePath ? [
619-
path.join(workspaceRoot, modulePath + '.js'),
620-
path.join(workspaceRoot, modulePath + '.ts'),
621-
path.join(workspaceRoot, modulePath + '.cjs'),
622-
path.join(workspaceRoot, modulePath),
623-
] : []),
612+
...(modulePath
613+
? [
614+
path.join(workspaceRoot, modulePath + '.js'),
615+
path.join(workspaceRoot, modulePath + '.ts'),
616+
path.join(workspaceRoot, modulePath + '.cjs'),
617+
path.join(workspaceRoot, modulePath)
618+
]
619+
: []),
624620
path.join(workspaceRoot, 'example/tests', testFile + '.js'),
625621
path.join(workspaceRoot, 'example/tests', testFile),
626622
path.join(workspaceRoot, 'tests', testFile + '.js'),

packages/nightwatch-devtools/src/session.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,14 @@ export class SessionCapturer {
573573
// Poll for collector — the async IIFE may take a moment to initialise
574574
let hasCollector = false
575575
for (let attempt = 0; attempt < 5; attempt++) {
576-
await browser.pause(200)
576+
await new Promise((resolve) => setTimeout(resolve, 200))
577577
const checkResult = await browser.execute(
578578
'return typeof window.wdioTraceCollector !== "undefined"'
579579
)
580580
hasCollector = ((checkResult as any)?.value ?? checkResult) === true
581-
if (hasCollector) break
581+
if (hasCollector) {
582+
break
583+
}
582584
}
583585

584586
if (hasCollector) {

0 commit comments

Comments
 (0)