Skip to content

Commit 623ed44

Browse files
committed
if cypress.env.debug is set, log command execution thru server
1 parent 0b4c3a4 commit 623ed44

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

packages/driver/src/cypress/cy.coffee

+10-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ setTopOnError = (cy) ->
6060
if curCy
6161
curCy = cy
6262
return
63-
63+
6464
curCy = cy
6565

6666
onTopError = ->
@@ -76,7 +76,7 @@ setTopOnError = (cy) ->
7676
configurable: false
7777
enumerable: true
7878
})
79-
79+
8080

8181
create = (specWindow, Cypress, Cookies, state, config, log) ->
8282
stopped = false
@@ -419,7 +419,13 @@ create = (specWindow, Cypress, Cookies, state, config, log) ->
419419

420420
Cypress.action("cy:command:start", command)
421421

422-
runCommand(command)
422+
423+
new Promise (resolve) ->
424+
if (a = Cypress.env('DEBUG'))
425+
return resolve(Cypress.backend('debug:command', command))
426+
resolve()
427+
.then ->
428+
runCommand(command)
423429
.then ->
424430
## each successful command invocation should
425431
## always reset the timeout for the current runnable
@@ -1133,7 +1139,7 @@ create = (specWindow, Cypress, Cookies, state, config, log) ->
11331139
args: obj
11341140
})
11351141
})
1136-
1142+
11371143
setTopOnError(cy)
11381144

11391145
## make cy global in the specWindow

packages/server/lib/socket.coffee

+4-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ class Socket
288288
## cb is always the last argument
289289
cb = args.pop()
290290

291-
debug("backend:request %o", { eventName, args })
291+
if eventName isnt 'debug:command'
292+
debug("backend:request %o", { eventName, args })
292293

293294
backendRequest = ->
294295
switch eventName
@@ -310,6 +311,8 @@ class Socket
310311
files.readFile(config.projectRoot, args[0], args[1])
311312
when "write:file"
312313
files.writeFile(config.projectRoot, args[0], args[1], args[2])
314+
when "debug:command"
315+
debug('command ran in driver: cy.%s %o', args[0].name, _.pick(args[0], 'args'))
313316
when "exec"
314317
exec.run(config.projectRoot, args[0])
315318
when "task"

0 commit comments

Comments
 (0)