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

Formatted errors does not show as formatted in cypress test runner #23679

Closed
Amitkahlon opened this issue Sep 4, 2022 · 8 comments · Fixed by #24687
Closed

Formatted errors does not show as formatted in cypress test runner #23679

Amitkahlon opened this issue Sep 4, 2022 · 8 comments · Fixed by #24687
Labels
good first issue Good for newcomers pkg/reporter This is due to an issue in the packages/reporter directory type: regression A bug that didn't appear until a specific Cy version release v10.0.0 🐛 Issue present since 10.0.0

Comments

@Amitkahlon
Copy link

Amitkahlon commented Sep 4, 2022

Current behavior

Cypress 10 new test runner omits formatting on errors such as new lines, tabs, etc.

Capture

Desired behavior

To be able to throw an error with formattings such as new lines, and tabs.
For example see how cypress dashboard prints the error below

Test code to reproduce

it.only('fail to format in test runner', { retries: 0 }, () => {
    Cypress.on('fail', (error, runnable) => {
      throw {
        ...error,
        message: `Failed to assert  event.\n\nExpectedValue:**${JSON.stringify(
          error.expected,
          null,
          4
        )}** \nActual args: **${JSON.stringify(error.actual, null, 4)}** \n
      `,
      };
    });

    cy.wrap({
      category: 'resources',
      name: 'action',
      label: 'copy_clipboard',
      target: 'keyboard',
      location: {
        title: 'favorites',
      },
      search: {
        clientSearchId: 'favorites',
        sessionId: 'favorites',
      },
      resources: {
        message: 'match(undefined)',
      },
      jsonData: {
        'action.trigger': 'command_bar',
      },
    }).should('deep.equal', {
      category: 'resources',
      name: 'action',
      target: 'keyboard',
      label: 'copy_clipboard',
      location: {
        title: 'favorites',
      },
      resources: [
        {
          id: 'UgfdGiIVw7NklNbHWSO-fw',
          list: 'favorites',
          appId: 'mockapp',
          type: 'mockapp:item',
          position: 0,
          linkId: '631483cead6377c7a8ef5c2e',
        },
      ],
      jsonData: {
        'action.trigger': 'command_bar',
      },
    });
  });

Cypress Version

10.7.0

Node version

16.14.2

Operating System

windows 10

Debug Logs

No response

Other

  • It worked well with cypress 9 and was broken with Cypress 10.
  • it actually works well in Cypress dashboard.

Cypress Dashboard showing formatted error

Capture

@emilyrohrbough
Copy link
Member

@Amitkahlon It does appear this used to work in 9.6.0 and no longer works in Cypress 10.7.0. Thank you for providing a reproducible example! I will make as a regression. That being said, I don't anticipate this issue will be picked up anytime soon. Would you be interested in contributing a fix to restore this behavior?

@Amitkahlon
Copy link
Author

Amitkahlon commented Sep 7, 2022

@Amitkahlon It does appear this used to work in 9.6.0 and no longer works in Cypress 10.7.0. Thank you for providing a reproducible example! I will make as a regression. That being said, I don't anticipate this issue will be picked up anytime soon. Would you be interested in contributing a fix to restore this behavior?

Yeah, that sounds interesting, can you point me in the right direction?
I will make my best attempt to fix it.

@emilyrohrbough
Copy link
Member

@Amitkahlon Great!! I did a little digging and I suspect it could be tied to this change: #22537 which was made to enhance the markdown formatting.

If it were me, I'd start with verifying the message is in the format you expected before we attempt to format it for the UI.

@Amitkahlon
Copy link
Author

@Amitkahlon Great!! I did a little digging and I suspect it could be tied to this change: #22537 which was made to enhance the markdown formatting.

If it were me, I'd start with verifying the message is in the format you expected before we attempt to format it for the UI.

Thank you, I will give it a try this weekend

@perlo27
Copy link

perlo27 commented Oct 16, 2022

Hi there,
i see this one being inactive for a while, i can fix it if no one mind

@Amitkahlon
Copy link
Author

Hi there, i see this one being inactive for a while, i can fix it if no one mind

Hi, yeah..
you can take it if you want

@perlo27
Copy link

perlo27 commented Oct 18, 2022

i have a fix ready, just can't push the branch - have 403 when pushing. @emilyrohrbough could you please help me with it?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 24, 2023

Released in 12.4.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jan 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers pkg/reporter This is due to an issue in the packages/reporter directory type: regression A bug that didn't appear until a specific Cy version release v10.0.0 🐛 Issue present since 10.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants