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

Bad formatting in Cypress soft assertions headless error messages #3200

Closed
MikeMcC399 opened this issue Nov 4, 2022 · 1 comment · Fixed by #3201
Closed

Bad formatting in Cypress soft assertions headless error messages #3200

MikeMcC399 opened this issue Nov 4, 2022 · 1 comment · Fixed by #3201
Labels
bug Something isn't working mirrored-to-jira

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Nov 4, 2022

Where to find the issue

Cypress test suite using soft assertions

Describe the issue

  • When running a Cypress test which uses soft assertions in headless mode, any error messages logged are badly formatted. They are missing the intended new lines between each error logged.

  • This is similar to the issue Error in Cypress softAssert error message format #3040 reported for headed mode.

Steps to reproduce

Temporarily edit src/data/faq.json and introduce several errors such as removing target='_blank' from two links.

In one terminal windows execute
npm start

Once the localhost website is shown in a browser, open a second terminal window and execute
npx cypress run -s 'cypress/e2e/faq_link_attr.cy.js'

A badly formatted message such as

  1 failing

  1) Check attributes of FAQ links
       Check links are using _blank to open in new frame
         Test links for _blank presence:
     Error: tnAssertionError: http://localhost:8000/en/faq/results/#risk_encounter_no_warning in /en/faq/results/: expected '<a>' to have attribute 'target'nAssertionError: http://localhost:8000/en/faq/results/#risk_encounter_different_devices in /en/faq/results/: expected '<a>' to have attribute 'target'
      at Context.eval (webpack:///./cypress/support/e2e.js:88:18)

will be displayed. The "t" is supposed to be a tab and the "n" is supposed to be a new line. There is no new line separating the individual errors so the output is very hard to read.

Suggestion

Correct the message format in

} else {
_.each( errors, error => {
msg += 'n' + error;
});
msg = msg.replace(/^/gm, 't');

  • n should be \n for new line
  • t should be \t for tab

(See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#escape_sequences.)


Internal Tracking ID: EXPOSUREAPP-14291

@MikeMcC399
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mirrored-to-jira
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants