Skip to content

Commit

Permalink
fix(logs): log the command properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Apr 19, 2018
1 parent 426ef5e commit a44bb83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 3 additions & 9 deletions cypress/integration/commands.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ describe('dom-testing-library commands', () => {
})

it('getByText', () => {
cy
.getByText('Button Text')
.click()
cy.getByText('Button Text').click()
})

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

it('getByAltText', () => {
cy
.getByAltText('Image Alt Text')
.click()
cy.getByAltText('Image Alt Text').click()
})

it('getByTestId', () => {
cy
.getByTestId('image-with-random-alt-tag')
.click()
cy.getByTestId('image-with-random-alt-tag').click()
})
})

Expand Down
13 changes: 12 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ const commands = Object.keys(queries)
}
`,
)(commandImpl)
return cy.window({log: false}).then(thenHandler)
return cy
.window({log: false})
.then(thenHandler)
.then(subject => {
Cypress.log({
$el: subject,
name: queryName,
message: args,
})
return subject
})
},
}
})

export {commands}

/* eslint no-new-func:0 */
/* globals Cypress */

0 comments on commit a44bb83

Please sign in to comment.