The Keyboard API allows you set the default values for how the .type() command is executed.
Cypress.Keyboard.defaults(options)
options (Object)
An object containing the following:
| Option | Default | Description |
|---|---|---|
keystrokeDelay |
10 |
The delay, in milliseconds, between keystrokes while typing with .type(). Set to 0 to remove the delay. Must be a non-negative number. |
Cypress.Keyboard.defaults({
keystrokeDelay: 20,
})
Cypress.Keyboard.defaults({
keystrokeDelay: 0,
})
A great place to put this configuration is in your cypress/support/index.js file, since it is loaded before any test files are evaluated.
The keystroke delay can also be set via test configuration, which can be useful when setting it for a single test or a subset of tests.
it('removes keystroke delay for all typing in this test', { keystrokeDelay: 0 }, () => {
cy.get('input').eq(0).type('fast typing')
cy.get('input').eq(1).type('more fast typing')
})
describe('removes keystroke delay in all tests in this suite', { keystrokeDelay: 0 }, () => {
it('types fast in the first input', () => {
cy.get('input').eq(0).type('fast typing')
})
it('types fast in the second input', () => {
cy.get('input').eq(1).type('more fast typing')
})
}))
© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/cypress-api/keyboard-api