-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/retryability #14
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
import { validateElement, validateSelector, validateSubject } from '../../validators'; | ||
import { validateSelector, validateSubject } from '../../validators'; | ||
import resolveValue from '../../helpers/resolveValue'; | ||
|
||
export default function shadowFind(subject, selector) { | ||
export default function shadowFind(subject, selector, options) { | ||
validateSubject(subject); | ||
validateSelector(selector); | ||
|
||
const currentElement = subject[0].shadowRoot || subject[0]; | ||
const foundElements = currentElement.querySelectorAll(selector); | ||
validateElement(foundElements[0]); | ||
const elGetter = () => { | ||
const currentElement = subject[0].shadowRoot || subject[0]; | ||
const found = currentElement.querySelectorAll(selector); | ||
|
||
Cypress.log({ | ||
name: 'shadowFind', | ||
message: `'${selector}'`, | ||
consoleProps: () => ({ | ||
selector, | ||
}), | ||
}); | ||
return found; | ||
}; | ||
|
||
return resolveValue(elGetter, options).then(foundElements => { | ||
Cypress.log({ | ||
name: 'shadowFind', | ||
message: `'${selector}'`, | ||
consoleProps: () => ({ | ||
selector, | ||
foundElements, | ||
}), | ||
}); | ||
|
||
return Cypress.cy.wrap(foundElements, { log: false }); | ||
return foundElements; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
import { validateElement, validateSelector } from '../../validators'; | ||
import { validateSelector } from '../../validators'; | ||
import resolveValue from '../../helpers/resolveValue'; | ||
|
||
export default selector => { | ||
export default (selector, options) => { | ||
validateSelector(selector); | ||
|
||
const element = Cypress.$(selector); | ||
validateElement(element); | ||
|
||
Cypress.log({ | ||
name: 'shadowGet', | ||
message: `'${selector}'`, | ||
consoleProps: () => ({ selector }), | ||
Cypress._.defaults(options, { | ||
log: true, | ||
timeout: 10000, | ||
abramenal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
return element; | ||
const elGetter = () => { | ||
return Cypress.$(selector); | ||
}; | ||
|
||
return resolveValue(elGetter, options).then(element => { | ||
Cypress.log({ | ||
name: 'shadowGet', | ||
message: `'${selector}'`, | ||
consoleProps: () => ({ selector, element }), | ||
}); | ||
|
||
return element; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function resolveValue(valueGetterFn, options = {}) { | ||
abramenal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return Cypress.Promise.try(valueGetterFn).then(value => { | ||
return Cypress.cy.verifyUpcomingAssertions(value, options, { | ||
onRetry: () => resolveValue(valueGetterFn, options), | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears
CommandOptions
is already declared as an interface in Cypress library.As such a typescript error is issued because you can't redeclare a type. Can we change this type name to
ShadowOptions
or something similar? If we extendCommandOptions
by declaring this an interface, it results inprevSubject
being required.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was awhile ago, but I'm having this exact problem. I'm using Typescript with Cypress and I am unable to specify a timeout on
shadowGet()
orshadowFind()
because{ timeout: 5000 }
is not assignable to parameter of typeCypress.CommandOptions
. Any chance this is something we could fix? I can open a new issue if necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see these typings were not updated properly:
https:/abramenal/cypress-shadow-dom/blob/master/index.d.ts#L25
Are you able to create a MR with that fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it as simple as changing the
shadowFind
,shadowFirst
,shadowGet
andshadowLast
methods to useShadowCommandOptions
? Also looks like you have a typo inShadowEventOptios
- I could fix that too.