Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from cypress-io/wrap-2
Browse files Browse the repository at this point in the history
feat: wrap returned elements in jquery, close #2
  • Loading branch information
bahmutov authored Dec 6, 2018
2 parents b791b1b + 8d48299 commit 53e1738
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See [cypress/integration/spec.js](cypress/integration/spec.js)

## Roadmap

- [ ] wrap returned DOM nodes in jQuery [#2](https://github.com/cypress-io/cypress-xpath/issues/2)
- [x] wrap returned DOM nodes in jQuery [#2](https://github.com/cypress-io/cypress-xpath/issues/2)
- [ ] retry the assertion that follows [#3](https://github.com/cypress-io/cypress-xpath/issues/3)
- [ ] add TypeScript definitions [#4](https://github.com/cypress-io/cypress-xpath/issues/4)
- [ ] search from the previous subject element [#5](https://github.com/cypress-io/cypress-xpath/issues/5)
Expand Down
7 changes: 7 additions & 0 deletions cypress/integration/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ describe('cypress-xpath', () => {
cy.xpath('//h1').should('have.length', 1)
})

it('returns jQuery wrapped elements', () => {
cy.visit('cypress/integration/index.html')
cy.xpath('//h1').then((el$) => {
expect(el$).to.have.property('jquery')
})
})

it('gets h1 text', () => {
cy.visit('cypress/integration/index.html')
cy.xpath('//h1/text()').its('0.textContent').should('equal', 'cypress-xpath')
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const xpath = (selector) => {

// TODO set found elements on the command log?

return nodes
return Cypress.$(nodes)
}

Cypress.Commands.add('xpath', xpath)

0 comments on commit 53e1738

Please sign in to comment.