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: error regression - strip ansi colors out of cy.fixture() error message #20335

Merged
merged 6 commits into from
Feb 28, 2022

Conversation

brian-mann
Copy link
Member

@brian-mann brian-mann commented Feb 23, 2022

User facing changelog

  • Fix regression that caused ANSI color colors to show up in cy.fixture(...) errors
  • Fix regression that test config override errors to format incorrectly

Additional details

Errors originating from the server (@packages/errors) were altered as part of a larger errors improvement here #20072. In this one particular code, ANSI color styles were showing up as a command log error.

How has the user experience changed?

Before
image

Screen Shot 2022-02-28 at 10 19 59 AM

Screen Shot 2022-02-28 at 10 29 34 AM

After
image

Screen Shot 2022-02-28 at 10 27 56 AM

Screen Shot 2022-02-28 at 10 30 26 AM

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)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@brian-mann brian-mann requested a review from a team as a code owner February 23, 2022 17:17
@brian-mann brian-mann requested review from jennifer-shehane and removed request for a team February 23, 2022 17:17
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 23, 2022

Thanks for taking the time to open a PR!

@brian-mann brian-mann changed the title fix cy.fixture regression - strip ansi colors out of fixture error me… fix: cy.fixture regression - strip ansi colors out of fixture error message Feb 23, 2022
@brian-mann brian-mann changed the title fix: cy.fixture regression - strip ansi colors out of fixture error message fix: error regression - strip ansi colors out of cy.fixture() error message Feb 23, 2022
@cypress
Copy link

cypress bot commented Feb 23, 2022



Test summary

19278 0 218 0Flakiness 1


Run details

Project cypress
Status Passed
Commit 16d98b8
Started Feb 28, 2022 4:44 PM
Ended Feb 28, 2022 4:56 PM
Duration 11:28 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

cypress/integration/cypress/proxy-logging_spec.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@jennifer-shehane jennifer-shehane removed their request for review February 23, 2022 17:51
mjhenkes
mjhenkes previously approved these changes Feb 23, 2022
Copy link
Member

@emilyrohrbough emilyrohrbough left a comment

Choose a reason for hiding this comment

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

Did a test need to be updated and/or added to ensure this is working as expected?

@brian-mann
Copy link
Member Author

brian-mann commented Feb 23, 2022

Did a test need to be updated and/or added to ensure this is working as expected?

An existing test was modified to ensure the err.message had ansi stripped. No new test needed to be written.

See here: https://github.com/cypress-io/cypress/pull/20335/files#diff-7bf5eaece2933de0e512e9c339f6f16e0c313696d05d1dab0cfe332f858be614R136

@brian-mann
Copy link
Member Author

Actually don't merge this yet - I have one other area to check to ensure ANSI styles aren't leaking out. Has to do with config validation when providing overrides to the it() or describe() definitions

// the @packages/error list, it should be written in
// the driver since this error can only occur within
// driver commands and not outside of the test runner
const err = errors.get('FIXTURE_NOT_FOUND', relativePath, extensions)
Copy link
Member

Choose a reason for hiding this comment

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

  1. Would it make more sense to update the error to remove the ansi from the FIXTURE_NOT_FOUND error (it has a // fix me comment we can remove).

  2. I assume there is risk other errors created in the server that's sent back to the driver will also need to strip out asni? It seem like it'd be safer to add this logic to the reporter directly in the error component: https://github.com/cypress-io/cypress/blob/develop/packages/reporter/src/errors/test-error.tsx#L73

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I was double checking - there is rarely a situation where we construct the error message in the server with ANSI styling AND send it through to the driver.

That's why I added the FIXME because there's no reason for the server to construct this error. The vast majority of the errors are formatted in the driver in this situation. That's why this broke to begin with. It's like a square peg in a round hole.

I looked into moving this fix more broadly into the server - but because this isn't actually the pattern we want to replicate it seemed fixing it only in this 1 place was most prudent. Once this error is moved into the driver it would obviate a need to ever need to do this in the server.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. Sounds like an easy fix that just needs to get done.

@emilyrohrbough
Copy link
Member

An existing test was modified to ensure the err.message had ansi stripped. No new test needed to be written.

Gottchya. I had expected a test within the packages/server to be updated since that's where the change was made.

@jennifer-shehane
Copy link
Member

I messaged @brian-mann to revisit.

@emilyrohrbough
Copy link
Member

Is there another regression example or did markdown syntax use to render in the command log?

Screen Shot 2022-02-25 at 4 21 59 PM

@brian-mann
Copy link
Member Author

Is there another regression example or did markdown syntax use to render in the command log?

Screen Shot 2022-02-25 at 4 21 59 PM

@emilyrohrbough I'm not sure what you mean here - it appears this is failing in a different branch (?)

@emilyrohrbough
Copy link
Member

@brian-mann yes a different branch off of develop - I was looking at the error message format & the markdown syntax in the terminal output.

@brian-mann
Copy link
Member Author

@emilyrohrbough I believe you're looking at our own custom formatted error for the snapshotting of mocha events - and this isn't representative of the way the system normally looks or behaves. From that error I can't really tell what is wrong or what should be expected to be there. If you could find a situation regarding a typical error case that's not using internal formatting / utilities I can take a look at it. From what I can tell though - I don't believe this is a regression anywhere.

@emilyrohrbough
Copy link
Member

@brian-mann Ok! Sounds good to me.

@brian-mann
Copy link
Member Author

Added additional user changelog item + before/after pics of the 2nd regression

emilyrohrbough
emilyrohrbough previously approved these changes Feb 28, 2022
mjhenkes
mjhenkes previously approved these changes Feb 28, 2022
@brian-mann brian-mann merged commit e0bd6ac into develop Feb 28, 2022
@brian-mann brian-mann deleted the fix/cy-fixture-error-regression branch February 28, 2022 17:01
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.

Error message regression
4 participants