Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customized assersion message not shown when using 'Cypress run' #14484

Labels
type: error message type: unexpected behavior User expected result, but got another

Comments

@iyangdidi
Copy link

Current behavior

I use following code to customize the assersion message
dossierPage.filerPanel.getCapsuleItems(filerName1).should(($lis) => { expect($lis, 'Filter "'+filerName1+'"should have 4 items').to.have.length(5) })
The customized message can be shown when using 'cypress open'
image

But

  1. can't shown when using 'cypress run'
    image
  2. the line number throw the error is not right

Desired behavior

  1. customized message should also be shown when using 'cypress run'
  2. the line number throw the error should be the right line number
    Here is an example of protractor as an reference
    image

Test code to reproduce

  1. any test scripts, add customized message to 'expect',
  2. fail the assersion
  3. run with 'cypress open'
  4. run with 'cypress run'
  5. check the failure information

Versions

"cypress": "^5.5.0",

@bahmutov
Copy link
Contributor

bahmutov commented Jan 11, 2021 via email

@jennifer-shehane
Copy link
Member

In this case, the actual error thrown does not contain the custom assertion error message and is instead overwritten by the Cypress error thrown. This is true in both cypress open and cypress run.

Cypress does show the custom error message in the Command Log in cypress open though, which is not visible during cypress run.

it('test', () => {
  cy.visit('index.html')
  cy.get('div').should(($divs) => {
    expect($divs, 'Filter should have 1 items').to.have.length(1)
  })
})
<html>
<body>
<div></div>
<div></div>
</body>
</html>

Screen Shot 2021-01-12 at 7 41 10 AM

The second issue about the stack trace line is a duplicate of this issue: #7715

@jennifer-shehane jennifer-shehane added the type: unexpected behavior User expected result, but got another label Jan 12, 2021
@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jan 12, 2021
@iyangdidi
Copy link
Author

@jennifer-shehane
Thanks for the prompt reply.
So are you plan to fix this? and how about the time plan?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 10, 2021

The code for this is done in cypress-io/cypress#14982, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: work in progress There is an open PR for this issue [WIP] labels Mar 10, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 15, 2021

Released in 6.7.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.7.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.