Skip to content

Commit a44bb83

Browse files
author
Kent C. Dodds
committed
fix(logs): log the command properly
1 parent 426ef5e commit a44bb83

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

cypress/integration/commands.spec.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ describe('dom-testing-library commands', () => {
1010
})
1111

1212
it('getByText', () => {
13-
cy
14-
.getByText('Button Text')
15-
.click()
13+
cy.getByText('Button Text').click()
1614
})
1715

1816
it('getByLabelText', () => {
@@ -23,15 +21,11 @@ describe('dom-testing-library commands', () => {
2321
})
2422

2523
it('getByAltText', () => {
26-
cy
27-
.getByAltText('Image Alt Text')
28-
.click()
24+
cy.getByAltText('Image Alt Text').click()
2925
})
3026

3127
it('getByTestId', () => {
32-
cy
33-
.getByTestId('image-with-random-alt-tag')
34-
.click()
28+
cy.getByTestId('image-with-random-alt-tag').click()
3529
})
3630
})
3731

src/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@ const commands = Object.keys(queries)
1717
}
1818
`,
1919
)(commandImpl)
20-
return cy.window({log: false}).then(thenHandler)
20+
return cy
21+
.window({log: false})
22+
.then(thenHandler)
23+
.then(subject => {
24+
Cypress.log({
25+
$el: subject,
26+
name: queryName,
27+
message: args,
28+
})
29+
return subject
30+
})
2131
},
2232
}
2333
})
2434

2535
export {commands}
2636

2737
/* eslint no-new-func:0 */
38+
/* globals Cypress */

0 commit comments

Comments
 (0)