Skip to content

Commit

Permalink
should() chaining (#6128)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh authored and jennifer-shehane committed Jan 10, 2020
1 parent ab7cc5f commit 957d76a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/driver/src/cy/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,18 @@ const create = function (state, queue, retryFn) {
// assertions
if (cmdHasFunctionArg(cmd)) {
let index = cmd.get('assertionIndex')
const assertions = cmd.get('assertions')
let assertions = cmd.get('assertions')

// https://github.com/cypress-io/cypress/issues/4981
// `assertions` is undefined because assertions added by
// `should` command are not handled yet.
// So, don't increase i and go back to the last command.
if (!assertions) {
i -= 1
cmd = cmds[i - 1]
index = cmd.get('assertionIndex')
assertions = cmd.get('assertions')
}

// always increase the assertionIndex
// so our next assertion matches up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,29 @@ describe('src/cy/commands/assertions', () => {
})
})

it('can be chained', () => {
cy.wrap('ab')
.should((subject) => {
expect(subject).to.be.a('string')
expect(subject).to.contain('a')
})
.should((subject) => {
expect(subject).to.contain('b')
expect(subject).to.have.length(2)
})
.and((subject) => {
expect(subject).to.eq('ab')
expect(subject).not.to.contain('c')
})
.then(function () {
expect(this.logs.length).to.eq(8)

this.logs.slice(1).forEach((log) => {
expect(log.get('name')).to.eq('assert')
})
})
})

context('remote jQuery instances', () => {
beforeEach(function () {
this.remoteWindow = cy.state('window')
Expand Down

4 comments on commit 957d76a

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 957d76a Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/linux-x64/circle-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-229267/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.2/circle-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-229225/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 957d76a Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/win32-ia32/appveyor-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-30016853/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.2/win32-ia32/appveyor-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-30016853/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 957d76a Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/win32-x64/appveyor-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-30016853/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.2/win32-x64/appveyor-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-30016853/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 957d76a Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/darwin-x64/circle-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-229328/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.2/circle-develop-957d76a190f42daa6598ff0e7911e76d29946e5c-229306/cypress.tgz

Please sign in to comment.