fix: keep spaces in formatted output in test runner
- Closes #23679
User facing changelog
Fixes issue where spaces on newlines weren't kept in the test runner
Additional details
The solution depends on tricking the markdown renderer into keeping any spaces by using the HTML entity   (a space). This will make it keep those, instead of disregarding it.
Steps to test
This is an example (taken from #23679) 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',
},
});
});
How has the user experience changed?
Before

After

PR Tasks
- [x] Have tests been added/updated?
- [ ] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
- [ ] Has a PR for user-facing changes been opened in
cypress-documentation? - [ ] Have API changes been updated in the
type definitions?
Thanks for taking the time to open a PR!
- Create a Draft Pull Request if your PR is not ready for review. Mark the PR as Ready for Review when you're ready for a Cypress team member to review the PR.
- Become familiar with the Code Review Checklist for guidelines on coding standards and what needs to be done before a PR can be merged.
I like this! Will approve once I have a chance to pull it down and test.
Thank you for your patience with our test failures - we've been working pretty heavily on stabilizing CI with 12.x, so here's hoping this latest merge of develop is the charm.
Looks like we do have one set of genuine failures, https://app.circleci.com/pipelines/github/cypress-io/cypress/47068/workflows/85b8f7a4-c7db-421a-92f4-9ce84e0cb8b5/jobs/1971826.
Specifically, these tests https://github.com/cypress-io/cypress/blob/develop/packages/app/cypress/e2e/runner/retries.ui.cy.ts#L325 are failing because it's asserting that the replaced text (with text like { retries: 2 }) matches the base text (with text like { retries: 2 }). Probably need to either decode the string before asserting on it, or encode the string it's asserted against.
@melkstam are you able to take a look at these failures?
@melkstam are you able to take a look at these failures?
Yes, I will look at it!