Skip to content

Commit 2f62901

Browse files
authored
fix: remove extra command log message for get* queries (#106)
Related to #103
1 parent da1dc4d commit 2f62901

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

cypress/integration/get.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ describe('get* queries should error', () => {
1919

2020
cy[`${obsoleteQueryName}`]('Irrelevant')
2121
})
22+
23+
it(`${obsoleteQueryName} should not log more than once`, () => {
24+
25+
let logCount = 0
26+
cy.on('log:added', (attrs, log) => {
27+
if (log.get('name') === obsoleteQueryName) {
28+
logCount = logCount + 1
29+
}
30+
})
31+
32+
cy.on('fail', _ => {
33+
expect(logCount).to.equal(1)
34+
cy.removeAllListeners('log:added')
35+
})
36+
37+
cy[`${obsoleteQueryName}`]('Irrelevant')
38+
})
2239
})
2340
})
2441
})

src/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ const getCommands = getQueryNames.map(queryName => {
2121
return {
2222
name: queryName,
2323
command: () => {
24-
Cypress.log({
25-
name: queryName,
26-
})
27-
2824
throw new Error(
2925
`You used '${queryName}' which has been removed from Cypress Testing Library because it does not make sense in this context. Please use '${queryName.replace(
3026
getRegex,

0 commit comments

Comments
 (0)