Skip to content

Commit

Permalink
fix(#290): Do not use optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrea committed Aug 26, 2023
1 parent da0e039 commit b1ee502
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Removed
### BREAKING CHANGES

## [unreleased]

### Fixed
- fix(#290): Do not use optional chaining. It was producing an error in Cypress. See https://github.com/cypress-io/cypress/issues/9298

## [7.0.2] - 2023-08-16

### Changed
Expand Down
16 changes: 11 additions & 5 deletions src/helpers/cypress.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function isHeaded(Cypress) {
return Cypress.browser?.isHeaded;
return Cypress.browser && Cypress.browser.isHeaded;
}

function testHasFailed(currentTest) {
Expand Down Expand Up @@ -55,16 +55,22 @@ function getTestConfig(test) {
}
// Cypress >9
if (
test.ctx?.test?._testConfig?.testConfigList?.[
test.ctx?.test?._testConfig?.testConfigList?.length - 1
]?.overrides
test.ctx &&
test.ctx.test &&
test.ctx.test._testConfig &&
test.ctx.test._testConfig.testConfigList &&
test.ctx.test._testConfig.testConfigList[
test.ctx.test._testConfig.testConfigList.length - 1
] &&
test.ctx.test._testConfig.testConfigList[test.ctx.test._testConfig.testConfigList.length - 1]
.overrides
) {
return test.ctx.test._testConfig.testConfigList[
test.ctx.test._testConfig.testConfigList.length - 1
].overrides;
}
// Cypress >6.7
if (test.ctx?.test?._testConfig) {
if (test.ctx && test.ctx.test && test.ctx.test._testConfig) {
return test.ctx.test._testConfig;
}
return {};
Expand Down

0 comments on commit b1ee502

Please sign in to comment.