Skip to content

Commit 24ef4e0

Browse files
committed
chore: Address usability issues
- Removing `disableDebugger` - Introducing `#lastActionTimestamp` - Adding `--fix` flag in eslint scripts
1 parent b8443a3 commit 24ef4e0

7 files changed

Lines changed: 21 additions & 40 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ selenium-video-*.webm
3434
nightwatch-video-*.webm
3535
packages/nightwatch-devtools/nightwatch-video-*.webm
3636

37-
# trace.zip output (mode: 'trace')
37+
# trace output (mode: 'trace')
3838
trace-*.zip
39-
trace-*/
39+
examples/**/trace-*/
4040

4141
# vitest --coverage output
4242
coverage/

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"types": "./src/index.ts",
4040
"scripts": {
41-
"lint": "eslint ."
41+
"lint": "eslint . --fix"
4242
},
4343
"license": "MIT",
4444
"devDependencies": {

packages/core/src/trace-exporter.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,12 @@ function buildActionEvents(
165165
const endMs = Math.max(startMs + 1, rawEndMs)
166166
const rawArgs = cmd.args as unknown[]
167167
let params: Record<string, unknown>
168-
if (
169-
action.class === 'Element' &&
170-
action.method === 'fill' &&
171-
rawArgs.length >= 2
172-
) {
168+
const isValueMethod = FILL_METHODS.has(action.method)
169+
if (action.class === 'Element' && isValueMethod && rawArgs.length >= 2) {
173170
params = { selector: rawArgs[0], value: rawArgs[1] }
174171
} else if (
175172
action.class === 'Element' &&
176-
action.method === 'fill' &&
173+
isValueMethod &&
177174
rawArgs.length === 1
178175
) {
179176
params = { value: rawArgs[0] }

packages/service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"scripts": {
3232
"dev": "vite build --watch",
3333
"build": "tsc && vite build",
34-
"lint": "eslint .",
34+
"lint": "eslint . --fix",
3535
"prepublishOnly": "pnpm build"
3636
},
3737
"dependencies": {

packages/service/src/index.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,23 @@ export default class DevToolsHookService implements Services.ServiceInstance {
219219
if (this.#options.mode !== 'trace' || !this.#browser) {
220220
return
221221
}
222+
const stamp = this.#lastActionTimestamp()
223+
const snap = await captureActionSnapshot(this.#browser, '__final__')
224+
if (snap) {
225+
snap.timestamp = stamp
226+
this.#actionSnapshots.push(snap)
227+
}
228+
}
229+
230+
#lastActionTimestamp(): number {
222231
const commands = this.#sessionCapturer.commandsLog
223-
let stamp = Date.now()
224232
for (let i = commands.length - 1; i >= 0; i--) {
225233
const cmd = commands[i]!
226234
if (mapCommandToAction(cmd.command)) {
227-
stamp = cmd.timestamp
228-
break
235+
return cmd.timestamp
229236
}
230237
}
231-
const snap = await captureActionSnapshot(this.#browser, '__final__')
232-
if (snap) {
233-
snap.timestamp = stamp
234-
this.#actionSnapshots.push(snap)
235-
}
238+
return Date.now()
236239
}
237240

238241
private resetStack() {
@@ -320,16 +323,7 @@ export default class DevToolsHookService implements Services.ServiceInstance {
320323
) {
321324
const snap = await captureActionSnapshot(this.#browser, command)
322325
if (snap) {
323-
const commands = this.#sessionCapturer.commandsLog
324-
let stamp = 0
325-
for (let i = commands.length - 1; i >= 0; i--) {
326-
const cmd = commands[i]!
327-
if (mapCommandToAction(cmd.command)) {
328-
stamp = cmd.timestamp
329-
break
330-
}
331-
}
332-
snap.timestamp = stamp
326+
snap.timestamp = this.#lastActionTimestamp()
333327
this.#actionSnapshots.push(snap)
334328
}
335329
}

packages/service/src/launcher.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,8 @@ export class DevToolsAppLauncher {
110110
}
111111

112112
async onPrepare(_: never, caps: ExtendedCapabilities[]) {
113-
if (this.#options.mode === 'trace' || this.#options.disableDebugger) {
114-
log.info(
115-
this.#options.mode === 'trace'
116-
? 'Trace mode — skipping backend and Chrome window'
117-
: 'Debugger disabled — skipping backend and Chrome window'
118-
)
113+
if (this.#options.mode === 'trace') {
114+
log.info('Trace mode — skipping backend and Chrome window')
119115
return
120116
}
121117
try {

packages/service/src/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ export interface ServiceOptions {
6969
screencast?: ScreencastOptions
7070
/** `live` (default) launches the DevTools UI; `trace` skips it. */
7171
mode?: DevToolsMode
72-
/**
73-
* Skip launching the devtools dashboard backend and Chrome UI window
74-
* (default: false). Use when only trace recording is needed — no
75-
* debug dashboard, no extra Chrome window, no backend server.
76-
*/
77-
disableDebugger?: boolean
7872
/** Trace output layout — `zip` (default) writes a single archive,
7973
* `ndjson-directory` unpacks into `trace-<id>/`. Only applies in trace mode. */
8074
traceFormat?: TraceFormat

0 commit comments

Comments
 (0)