Skip to content

Commit 28df5f7

Browse files
authored
feat(cypress): make 'press' command work in cypress 13/react 17 and undo setup in r17-tests-v9 (microsoft#35107)
1 parent a434200 commit 28df5f7

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

apps/react-17-tests-v9/config/support/commands.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/react-17-tests-v9/config/support/component.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/react-17-tests-v9/cypress-react-17.config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ const specs = [
1313
path.resolve('../../packages/react-components/react-tabster/src/**/*.cy.{tsx,ts}'),
1414
...excludedSpecs,
1515
];
16-
const config = {
17-
...baseConfig,
18-
component: {
19-
...baseConfig.component,
20-
supportFile: path.resolve(__dirname, 'config/support/component.js'),
21-
},
22-
};
16+
const config = { ...baseConfig };
2317

2418
config.component.specPattern = specs;
2519
config.component.devServer.webpackConfig.resolve ??= {};

scripts/cypress/src/support/commands.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,14 @@
2828
/**
2929
* Navigates to storybook story URL based on component name and story name
3030
*/
31+
32+
/**
33+
* Press command fallback for Cypress 13 compatibility.
34+
* Registers only on Cypress v13, where `cy.press` is not built-in.
35+
*/
36+
const CYPRESS_MAJOR_VERSION =
37+
typeof Cypress !== 'undefined' && Cypress.version ? Number(String(Cypress.version).split('.')[0]) : undefined;
38+
39+
if (CYPRESS_MAJOR_VERSION === 13) {
40+
Cypress.Commands.add('press', /** @type {any} */ (require('cypress-real-events/commands/realPress').realPress));
41+
}

0 commit comments

Comments
 (0)