-
Notifications
You must be signed in to change notification settings - Fork 155
feat(within): Support cy.within #11
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 |
---|---|---|
|
@@ -47,7 +47,8 @@ | |
"contributions": [ | ||
"code", | ||
"doc", | ||
"ideas" | ||
"ideas", | ||
"test" | ||
] | ||
} | ||
], | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -13,8 +13,8 @@ | |
"test": "npm-run-all --parallel test:unit test:cypress", | ||
"test:unit": "kcd-scripts test --no-watch", | ||
"test:unit:watch": "kcd-scripts test", | ||
"test:cypress:serve": "serve -l 13370 ./cypress/fixtures/test-app", | ||
"test:cypress:run": "cypress run", | ||
"test:cypress:serve": "serve --listen 13370 ./cypress/fixtures/test-app", | ||
"test:cypress:run": "wait-port --timeout 10000 localhost:13370 && cypress run", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
"test:cypress:open": "cypress open", | ||
"test:cypress": "npm-run-all --silent --parallel --race test:cypress:serve test:cypress:run", | ||
"test:cypress:dev": "npm-run-all --silent --parallel --race test:cypress:serve test:cypress:open", | ||
|
@@ -45,7 +45,8 @@ | |
"cypress": "^3.0.1", | ||
"kcd-scripts": "^0.37.0", | ||
"npm-run-all": "^4.1.2", | ||
"serve": "^7.2.0" | ||
"serve": "^7.2.0", | ||
"wait-port": "^0.2.2" | ||
}, | ||
"peerDependencies": { | ||
"cypress": "^2.1.0 || ^3.0.0" | ||
|
This file contains hidden or 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,7 +1,7 @@ | ||
import {commands} from './' | ||
|
||
commands.forEach(({name, command}) => { | ||
Cypress.Commands.add(name, command.bind(null, cy)) | ||
Cypress.Commands.add(name, command) | ||
}) | ||
|
||
/* global Cypress, cy */ | ||
/* global Cypress */ |
This file contains hidden or 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 hidden or 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,21 @@ | ||
function getFirstElement(jqueryOrElement) { | ||
if (Cypress.dom.isJquery(jqueryOrElement)) { | ||
return jqueryOrElement.get(0) | ||
} | ||
return jqueryOrElement | ||
} | ||
|
||
function getContainer(container) { | ||
const withinContainer = cy.state('withinSubject') | ||
if (withinContainer) { | ||
return getFirstElement(withinContainer) | ||
} | ||
return getFirstElement(container) | ||
} | ||
|
||
export { | ||
getFirstElement, | ||
getContainer, | ||
} | ||
|
||
/* globals Cypress, cy */ |
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's not clear from the documentation https://docs.cypress.io/api/commands/then.html#DOM-element , but as I remember,
.then
callback gets a jQuery collection in its first argument, not a single DOM element. Could you please verify this?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.
Oh I see, you use
Cypress.dom.isJquery(element)
to accept both jQuery collection and a single element as the container. This wasn't the case before, so likely requires a documentation update where thecontainer
option type is described.