Reputation: 55
I'm wanting to test our tests that we have written. For example, if a developer creates a test with the type command, for example:
cy.get('input').type('Hello, World')
I want to test if this type() has the option of log:false. If there is no option of log:false then fail the test.
Code should look like this:
cy.get('input').type('Hello, World', { log: false })
Has anyone using Cypress accomplished this? Running tests to test our tests.
Upvotes: 3
Views: 152
Reputation: 607
Not quite what you asked, but
/cypress/support/index.js
Cypress.Commands.overwrite('type', (originalFn, text, options) => {
// enforce no-log policy
return originalFn(text, { ...options, log: false })
})
Or if you like to finger-wag
Cypress.Commands.overwrite('type', (originalFn, text, options) => {
if (!options.log || options.log) {
throw " 👎 No logging allowed on .type()"
}
return originalFn(text, options)
})
Upvotes: 1