Skip to content

Commit

Permalink
refactor: Use optional chain expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrea committed Aug 15, 2023
1 parent 84884af commit 52c8912
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"es6": true
},
"parserOptions": {
"ecmaVersion": "2018"
"ecmaVersion": 2022
},
"plugins": ["prettier"],
"rules": {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- chore(deps): Update devDependencies
- chore(deps): Use NodeJs 16.x, 18.x and 20.x in pipelines
- refactor: Remove redundant double negation
- refactor: Use optional chain expressions

### Added
- chore: Handle concurrency in pipelines
Expand Down
16 changes: 5 additions & 11 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 && Cypress.browser.isHeaded;
return Cypress.browser?.isHeaded;
}

function testHasFailed(currentTest) {
Expand Down Expand Up @@ -55,22 +55,16 @@ function getTestConfig(test) {
}
// Cypress >9
if (
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
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.ctx.test && test.ctx.test._testConfig) {
if (test.ctx?.test?._testConfig) {
return test.ctx.test._testConfig;
}
return {};
Expand Down

0 comments on commit 52c8912

Please sign in to comment.