Skip to content

Commit

Permalink
Fix option test failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh committed Jun 19, 2020
1 parent 5fa8724 commit 18b4685
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 12 deletions.
63 changes: 51 additions & 12 deletions packages/driver/cypress/integration/cy/options_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,72 @@ describe('last arg can be an object, but not an option', () => {
cy.wrap({}).invoke({ log: true }, 'non-exist')
})

it('nextUntil', () => {
cy.on('log:added', () => {
cy.removeAllListeners('log:added')
expect(this.logs[0].get('options')).to.deep.eq({})
it('nextUntil - jquery', () => {
cy.on('log:added', (attrs, log) => {
if (log.get('name') === 'nextUntil') {
cy.removeAllListeners('log:added')
expect(log.get('options')).to.deep.eq({})
}
})

cy.get('div').nextUntil(cy.$$('.warning'))
})

it('parentsUntil', () => {
cy.on('log:added', () => {
cy.removeAllListeners('log:added')
expect(this.logs[0].get('options')).to.deep.eq({})
it('nextUntil - DOM', () => {
cy.on('log:added', (attrs, log) => {
if (log.get('name') === 'nextUntil') {
cy.removeAllListeners('log:added')
expect(log.get('options')).to.deep.eq({})
}
})

cy.get('div').nextUntil(document.getElementsByClassName('warning')[0])
})

it('parentsUntil - jquery', () => {
cy.on('log:added', (attrs, log) => {
if (log.get('name') === 'parentsUntil') {
cy.removeAllListeners('log:added')
expect(log.get('options')).to.deep.eq({})
}
})

cy.get('div').parentsUntil(cy.$$('.warning'))
})

it('prevsUntil', () => {
cy.on('log:added', () => {
cy.removeAllListeners('log:added')
expect(this.logs[0].get('options')).to.deep.eq({})
it('parentsUntil - DOM', () => {
cy.on('log:added', (attrs, log) => {
if (log.get('name') === 'parentsUntil') {
cy.removeAllListeners('log:added')
expect(log.get('options')).to.deep.eq({})
}
})

cy.get('div').parentsUntil(document.getElementsByClassName('warning')[0])
})

it('prevUntil - jquery', () => {
cy.on('log:added', (attrs, log) => {
if (log.get('name') === 'prevUntil') {
cy.removeAllListeners('log:added')
expect(log.get('options')).to.deep.eq({})
}
})

cy.get('div').prevUntil(cy.$$('.warning'))
})

it('prevUntil - DOM', () => {
cy.on('log:added', (attrs, log) => {
if (log.get('name') === 'prevUntil') {
cy.removeAllListeners('log:added')
expect(log.get('options')).to.deep.eq({})
}
})

cy.get('div').prevUntil(document.getElementsByClassName('warning')[0])
})

it('select', () => {
cy.on('log:added', (attrs) => {
if (attrs.name === 'select') {
Expand Down
5 changes: 5 additions & 0 deletions packages/driver/src/cy/commands/traversals.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ module.exports = (Commands, Cypress, cy) => {
options = arg2
}

// jQuery or DOM object is not an option
if ($dom.isJquery(options) || $dom.isElement(options)) {
options = {}
}

const userOptions = options || {}

options = _.defaults({}, userOptions, { log: true })
Expand Down

0 comments on commit 18b4685

Please sign in to comment.