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

Commit 53e1738

Browse files
authored
Merge pull request #11 from cypress-io/wrap-2
feat: wrap returned elements in jquery, close #2
2 parents b791b1b + 8d48299 commit 53e1738

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ See [cypress/integration/spec.js](cypress/integration/spec.js)
2929

3030
## Roadmap
3131

32-
- [ ] wrap returned DOM nodes in jQuery [#2](https://github.com/cypress-io/cypress-xpath/issues/2)
32+
- [x] wrap returned DOM nodes in jQuery [#2](https://github.com/cypress-io/cypress-xpath/issues/2)
3333
- [ ] retry the assertion that follows [#3](https://github.com/cypress-io/cypress-xpath/issues/3)
3434
- [ ] add TypeScript definitions [#4](https://github.com/cypress-io/cypress-xpath/issues/4)
3535
- [ ] search from the previous subject element [#5](https://github.com/cypress-io/cypress-xpath/issues/5)

cypress/integration/spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ describe('cypress-xpath', () => {
1010
cy.xpath('//h1').should('have.length', 1)
1111
})
1212

13+
it('returns jQuery wrapped elements', () => {
14+
cy.visit('cypress/integration/index.html')
15+
cy.xpath('//h1').then((el$) => {
16+
expect(el$).to.have.property('jquery')
17+
})
18+
})
19+
1320
it('gets h1 text', () => {
1421
cy.visit('cypress/integration/index.html')
1522
cy.xpath('//h1/text()').its('0.textContent').should('equal', 'cypress-xpath')

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const xpath = (selector) => {
6565

6666
// TODO set found elements on the command log?
6767

68-
return nodes
68+
return Cypress.$(nodes)
6969
}
7070

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

0 commit comments

Comments
 (0)