feat: escape key for cy.press (#32545)

* feat: escape key for cy.press

* changelog

* on-link to cy.press() in changelog
This commit is contained in:
Cacie Prins
2025-09-23 10:48:12 -04:00
committed by GitHub
parent 17c1ede5f6
commit 8755160a68
8 changed files with 15 additions and 3 deletions

View File

@@ -1,8 +1,12 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 15.2.1
## 15.3.0
_Released 9/23/2025 (PENDING)_
**Features:**
- Added Escape key support to [`cy.press()`](http://on.cypress.io/api/press). Addresses[#32429](https://github.com/cypress-io/cypress/issues/32429). Addressed in [#32545](https://github.com/cypress-io/cypress/pull/32545).
**Bugfixes:**
- In development mode, Electron `stderr` is piped directly to Cypress' `stderr` to make it clear why Electron failed to start, if it fails to start. Fixes [#32358](https://github.com/cypress-io/cypress/issues/32358). Addressed in [32468](https://github.com/cypress-io/cypress/pull/32468).

View File

@@ -12,7 +12,8 @@ declare namespace Cypress {
'Tab' |
'Backspace' |
'Delete' |
'Insert'
'Insert' |
'Escape'
type SupportedKey = SupportedNamedKey | string | number
}

View File

@@ -698,6 +698,7 @@ declare namespace Cypress {
SPACE: 'Space',
DELETE: 'Delete',
INSERT: 'Insert',
ESC: 'Escape',
},
}

View File

@@ -8,7 +8,7 @@ describe('src/cy/commands/actions/press', () => {
cy.visit('/fixtures/input_events.html')
})
it('fires the click event on the button when the named key is sent', () => {
it('fires the click event on the button when the named key for Space is sent', () => {
cy.get('#button').focus()
cy.get('#button').should('be.focused')
cy.press(Cypress.Keyboard.Keys.SPACE)

View File

@@ -1412,6 +1412,7 @@ const Keys: Record<string, Cypress.SupportedNamedKey> = {
SPACE: 'Space',
DELETE: 'Delete',
INSERT: 'Insert',
ESC: 'Escape',
}
export default {

View File

@@ -5,6 +5,9 @@ export default [
...baseConfig,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: __dirname,
},
globals: {
...globals.node,
globalThis: 'readonly',

View File

@@ -121,6 +121,7 @@ export const BidiOverrideCodepoints: Record<SupportedNamedKey, string> = {
'Delete': '\uE017',
'Insert': '\uE016',
'Space': '\uE00D',
'Escape': '\uE00C',
}
// any is fine to be used here because the key must be typeguarded before it can be used as a supported key

View File

@@ -27,6 +27,7 @@ export const NamedKeys: SupportedNamedKey[] = [
SpaceKey,
'Delete',
'Insert',
'Escape',
]
// utility type to enable the SupportedKey union type