mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-28 10:49:48 -05:00
feat: Add keystrokeDelay (#15683)
* Add keystrokeDelay * Config tests * Add proper comments * Add some tests for configuring timeout * Add tests for false values * Few additional tests * Rename test * feat: add Cypress.Keyboard.defaults() for specifying default keystrokeDelay * use test-configuration on link * remove obsolete error message * fix types and add type tests * fix types tests * fix type test Co-authored-by: Chris Breiding <chrisbreiding@gmail.com>
This commit is contained in:
Vendored
+20
@@ -490,6 +490,13 @@ declare namespace Cypress {
|
||||
getElementCoordinatesByPositionRelativeToXY(element: JQuery | HTMLElement, x: number, y: number): ElementPositioning
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://on.cypress.io/keyboard-api
|
||||
*/
|
||||
Keyboard: {
|
||||
defaults(options: Partial<KeyboardDefaultsOptions>): void
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://on.cypress.io/api/api-server
|
||||
*/
|
||||
@@ -2786,6 +2793,7 @@ declare namespace Cypress {
|
||||
|
||||
interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'animationDistanceThreshold' | 'baseUrl' | 'defaultCommandTimeout' | 'env' | 'execTimeout' | 'includeShadowDom' | 'requestTimeout' | 'responseTimeout' | 'retries' | 'scrollBehavior' | 'taskTimeout' | 'viewportHeight' | 'viewportWidth' | 'waitForAnimations'>> {
|
||||
browser?: IsBrowserMatcher | IsBrowserMatcher[]
|
||||
keystrokeDelay?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2836,6 +2844,18 @@ declare namespace Cypress {
|
||||
env: object
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for Cypress.Keyboard.defaults()
|
||||
*/
|
||||
interface KeyboardDefaultsOptions {
|
||||
/**
|
||||
* Time, in milliseconds, between each keystroke when typing. (Pass 0 to disable)
|
||||
*
|
||||
* @default 10
|
||||
*/
|
||||
keystrokeDelay: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Full set of possible options for cy.request call
|
||||
*/
|
||||
|
||||
@@ -592,17 +592,19 @@ namespace CypressTestConfigOverridesTests {
|
||||
browser: [{name: 'firefox'}, {name: 'chrome'}]
|
||||
}, () => {})
|
||||
it('test', {
|
||||
browser: 'firefox'
|
||||
browser: 'firefox',
|
||||
keystrokeDelay: 0
|
||||
}, () => {})
|
||||
it('test', {
|
||||
browser: {foo: 'bar'} // $ExpectError
|
||||
browser: {foo: 'bar'}, // $ExpectError
|
||||
}, () => {})
|
||||
|
||||
it('test', {
|
||||
retries: null
|
||||
retries: null,
|
||||
keystrokeDelay: 0
|
||||
}, () => { })
|
||||
it('test', {
|
||||
retries: 3
|
||||
retries: 3,
|
||||
keystrokeDelay: false, // $ExpectError
|
||||
}, () => { })
|
||||
it('test', {
|
||||
retries: {
|
||||
@@ -631,14 +633,16 @@ namespace CypressTestConfigOverridesTests {
|
||||
// set config on a per-suite basis
|
||||
describe('suite', {
|
||||
browser: {family: 'firefox'},
|
||||
baseUrl: 'www.example.com'
|
||||
baseUrl: 'www.example.com',
|
||||
keystrokeDelay: 0
|
||||
}, () => {})
|
||||
|
||||
context('suite', {}, () => {})
|
||||
|
||||
describe('suite', {
|
||||
browser: {family: 'firefox'},
|
||||
baseUrl: 'www.example.com'
|
||||
baseUrl: 'www.example.com',
|
||||
keystrokeDelay: false // $ExpectError
|
||||
foo: 'foo' // $ExpectError
|
||||
}, () => {})
|
||||
|
||||
@@ -672,3 +676,18 @@ namespace CypressTaskTests {
|
||||
val // $ExpectType unknown
|
||||
})
|
||||
}
|
||||
|
||||
namespace CypressKeyboardTests {
|
||||
Cypress.Keyboard.defaults({
|
||||
keystrokeDelay: 0
|
||||
})
|
||||
Cypress.Keyboard.defaults({
|
||||
keystrokeDelay: 500
|
||||
})
|
||||
Cypress.Keyboard.defaults({
|
||||
keystrokeDelay: false // $ExpectError
|
||||
})
|
||||
Cypress.Keyboard.defaults({
|
||||
delay: 500 // $ExpectError
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user