Skip to content

Commit 9a3a430

Browse files
committed
feat: print duration in the console when clicking on the command
1 parent 890fe5b commit 9a3a430

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

__snapshots__/cypress-failed-log-spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ exports['saved commands from long-name-spec.js 184-188-192-196-200-204-208-212-2
4545
]
4646

4747
exports['spec a.js finished with'] = {
48-
"totalTests": 3,
48+
"totalTests": 4,
4949
"totalFailed": 2,
50-
"totalPassed": 1,
50+
"totalPassed": 2,
5151
"totalPending": 0,
5252
"totalSkipped": 0
5353
}

cypress/integration/a.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ describe('root suite', () => {
1010
cy.wrap(person).its('name').should('equal', 'Mo')
1111
setTimeout(() => {
1212
person.name = 'Mo'
13+
14+
setTimeout(() => {
15+
person.name = 'Joe'
16+
}, 2000)
1317
}, 2000)
18+
19+
cy.wrap(person).its('name').should('equal', 'Joe')
20+
1421
})
1522

1623
it('has second test (failing)', () => {

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ function startLogging () {
8080

8181
Cypress.on('log:changed', options => {
8282
if (options.instrument === 'command' && options.consoleProps) {
83+
// This is NOT the exact command duration, since we are only
84+
// getting an event some time after the command finishes.
85+
// Still better to have approximate value than nothing
8386
options.wallClockStoppedAt = Date.now()
8487
options.duration = +options.wallClockStoppedAt - (+ new Date(options.wallClockStartedAt))
8588
options.consoleProps.Duration = options.duration

0 commit comments

Comments
 (0)