Skip to content

Commit

Permalink
fix: Throw error when assertion contains only one language chainer (#…
Browse files Browse the repository at this point in the history
…8105)

Co-authored-by: Jennifer Shehane <[email protected]>
  • Loading branch information
laistomazz and jennifer-shehane authored Aug 26, 2020
1 parent 949448f commit 1d7abce
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/driver/cypress/integration/commands/assertions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,24 @@ describe('src/cy/commands/assertions', () => {
cy.noop({}).should('dee.eq', {})
})

describe('language chainers err', () => {
// https://github.com/cypress-io/cypress/issues/883
const langChainers = ['to', 'be', 'been', 'is', 'that', 'which', 'and', 'has', 'have', 'with', 'at', 'of', 'same', 'but', 'does', 'still']

langChainers.forEach((langChainer) => {
it(`throws err when assertion contains only one language chainer: ${langChainer}`, (done) => {
cy.on('fail', (err) => {
expect(err.message).to.eq(`The chainer \`${langChainer}\` is a language chainer provided to improve the readability of your assertions, not an actual assertion. Please provide a valid assertion.`)
expect(err.docsUrl).to.eq('https://on.cypress.io/assertions')

done()
})

cy.noop(true).should(langChainer, true)
})
})
})

it('throws err when ends with a non available chainable', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.eq('The chainer `eq2` was not found. Could not build assertion.')
Expand Down
8 changes: 8 additions & 0 deletions packages/driver/src/cy/commands/asserting.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ module.exports = function (Commands, Cypress, cy, state) {
throwAndLogErr(err)
}

// https://github.com/cypress-io/cypress/issues/883
// A single chainer used that is not an actual assertion, like '.should('be', 'true')'
if (chainers.length < 2 && !_.isFunction(memo[value]) && !isCheckingExistence) {
err = $errUtils.cypressErrByPath('should.language_chainer', { args: { originalChainers } })
err.retry = false
throwAndLogErr(err)
}

return applyChainer(memo, value)
}, exp)

Expand Down
4 changes: 4 additions & 0 deletions packages/driver/src/cypress/error_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,10 @@ module.exports = {

should: {
chainer_not_found: 'The chainer `{{chainer}}` was not found. Could not build assertion.',
language_chainer: {
message: 'The chainer `{{originalChainers}}` is a language chainer provided to improve the readability of your assertions, not an actual assertion. Please provide a valid assertion.',
docsUrl: 'https://on.cypress.io/assertions',
},
eventually_deprecated: 'The `eventually` assertion chainer has been deprecated. This is now the default behavior so you can safely remove this word and everything should work as before.',
},

Expand Down

4 comments on commit 1d7abce

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1d7abce Aug 26, 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/5.0.1/linux-x64/circle-develop-1d7abce555d024bbae697133ff9329156461cfc0-431867/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/circle-develop-1d7abce555d024bbae697133ff9329156461cfc0-431839/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1d7abce Aug 26, 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.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1d7abce Aug 26, 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.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1d7abce555d024bbae697133ff9329156461cfc0-34856402/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1d7abce Aug 26, 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/5.0.1/darwin-x64/circle-develop-1d7abce555d024bbae697133ff9329156461cfc0-431877/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/circle-develop-1d7abce555d024bbae697133ff9329156461cfc0-431875/cypress.tgz

Please sign in to comment.