Skip to content

Commit

Permalink
fix: remove extra command log message for get* queries (#106)
Browse files Browse the repository at this point in the history
Related to #103
  • Loading branch information
NicholasBoll authored Jan 29, 2020
1 parent da1dc4d commit 2f62901
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 17 additions & 0 deletions cypress/integration/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ describe('get* queries should error', () => {

cy[`${obsoleteQueryName}`]('Irrelevant')
})

it(`${obsoleteQueryName} should not log more than once`, () => {

let logCount = 0
cy.on('log:added', (attrs, log) => {
if (log.get('name') === obsoleteQueryName) {
logCount = logCount + 1
}
})

cy.on('fail', _ => {
expect(logCount).to.equal(1)
cy.removeAllListeners('log:added')
})

cy[`${obsoleteQueryName}`]('Irrelevant')
})
})
})
})
Expand Down
4 changes: 0 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const getCommands = getQueryNames.map(queryName => {
return {
name: queryName,
command: () => {
Cypress.log({
name: queryName,
})

throw new Error(
`You used '${queryName}' which has been removed from Cypress Testing Library because it does not make sense in this context. Please use '${queryName.replace(
getRegex,
Expand Down

0 comments on commit 2f62901

Please sign in to comment.