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

fix: keep spaces in formatted output in test runner #24687

Merged
merged 19 commits into from
Jan 10, 2023

Conversation

melkstam
Copy link
Contributor

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
before

After
after

PR Tasks

  • 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?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 15, 2022

Thanks for taking the time to open a PR!

Copy link
Collaborator

@ryanthemanuel ryanthemanuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you for the contribution!

@marktnoonan
Copy link
Contributor

I like this! Will approve once I have a chance to pull it down and test.

@mjhenkes mjhenkes self-assigned this Nov 23, 2022
Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to look into the CI failure 🤔 , it's unrelated to the PR.

@emilyrohrbough emilyrohrbough changed the base branch from develop to matth/chore/disable-commercial-recomendations-take-2 November 29, 2022 22:42
@emilyrohrbough emilyrohrbough changed the base branch from matth/chore/disable-commercial-recomendations-take-2 to develop November 29, 2022 22:43
@BlueWinds
Copy link
Contributor

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.

@BlueWinds
Copy link
Contributor

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.

@emilyrohrbough
Copy link
Member

@melkstam are you able to take a look at these failures?

@melkstam
Copy link
Contributor Author

melkstam commented Jan 6, 2023

@melkstam are you able to take a look at these failures?

Yes, I will look at it!

@astone123 astone123 merged commit 870a658 into cypress-io:develop Jan 10, 2023
AtofStryker pushed a commit that referenced this pull request Jan 11, 2023
Co-authored-by: Emily Rohrbough <[email protected]>
Co-authored-by: Mark Noonan <[email protected]>
Co-authored-by: Matt Henkes <[email protected]>
Co-authored-by: Blue F <[email protected]>
@melkstam melkstam deleted the issue-23679 branch January 13, 2023 10:05
tgriesser added a commit that referenced this pull request Jan 18, 2023
* develop: (45 commits)
  fix: re-enable CYPRESS_INTERNAL_VITE_DEV development (#25364)
  fix: add skip domain injection description (#25463)
  fix: revert CSP header and script-src addition (#25445)
  chore: Update v8 snapshot cache (#25401)
  feat: Do not strip CSP headers from HTTPResponse (#24760)
  fix: keep spaces in formatted output in test runner (#24687)
  fix: Restrict dependency versions to known supported ranges (#25380)
  chore: Update v8 snapshot cache (#25370)
  feat: experimental skip domain injection (#25307)
  chore: support vite v4 for component testing (#25365)
  feat: Use JSX/TSX in generated spec filenames (#25318)
  docs(angular): Properties that are spied upon have to be defined within `componentProperties` instead of on root level. (#25359)
  chore: remove lint-changed from scripts/docs (#25308)
  chore: bump to 12.3.0 [skip ci] (#25355)
  fix: make NODE_ENV "production" for prod builds of launchpad (#25320)
  fix: .contains() should only return one element at all times (#25250)
  feat: add currentRetry to Cypress API (#25297)
  chore: release @cypress/webpack-dev-server-v3.2.2
  chore: release create-cypress-tests-v2.0.1
  fix: change wording for spec creation (#25271)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatted errors does not show as formatted in cypress test runner
7 participants