Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.72 KB

no-force.md

File metadata and controls

51 lines (37 loc) · 1.72 KB

disallow using of 'force: true' option (no-force)

Using force: true on inputs appears to be confusing rather than helpful. It usually silences the actual problem instead of providing a way to overcome it. See Cypress Core Concepts.

If enabling this rule, it's recommended to set the severity to warn.

Rule Details

This rule aims to disallow using of the force option on:.click(), .dblclick(), .type(), .rightclick(), .select(), .focus(), .check(), and .trigger(). Examples of incorrect code for this rule:

cy.get('button').click({force: true})
cy.get('button').dblclick({force: true})
cy.get('input').type('somth', {force: true})
cy.get('div').find('.foo').find('.bar').trigger('change', {force: true})
cy.get('input').trigger('click', {force: true})
cy.get('input').rightclick({force: true})
cy.get('input').check({force: true})
cy.get('input').select({force: true})
cy.get('input').focus({force: true})

Examples of correct code for this rule:

cy.get('button').click()
cy.get('button').click({multiple: true})
cy.get('button').dblclick()
cy.get('input').type('somth')
cy.get('input').trigger('click', {anyoption: true})
cy.get('input').rightclick({anyoption: true})
cy.get('input').check()
cy.get('input').select()
cy.get('input').focus()

When Not To Use It

If you don't mind using { force: true } with action commands, then turn this rule off.