question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatted errors does not show as formatted in cypress test runner

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Amitkahloncommented, Oct 17, 2022

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

1reaction
Amitkahloncommented, Sep 14, 2022

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best Practices - Cypress Documentation
Real World Practices The Cypress team maintains the Real World App (RWA), a full stack example application that demonstrates best practices and scalable....
Read more >
javascript - Cypress after each starts before test - Stack Overflow
I'm creating a cypress test suite, if I run one test all the hooks work correctly, ... For instructions on formatting see How...
Read more >
Unit test reports - GitLab Docs
If you don't use merge requests but still want to see the unit test report output ... First, GitLab Runner uploads all JUnit...
Read more >
Continuous Integration - cypress - w3resource
Finally, we will show you how to run tests in parallel on a CI. Setting up CI. Basics. Running Cypress in Continuous Integration...
Read more >
Install - Prettier
prettier --write . is great for formatting everything, but for a big project it ... "app/**/*.test.js" to format all tests in a directory...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found