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: cy.route swallows the error about missing fixture #7818 #7983

Merged
merged 1 commit into from
Jul 27, 2020

Conversation

przemuh
Copy link
Contributor

@przemuh przemuh commented Jul 14, 2020

User facing changelog

  • cy.route throws an error when fixture cannot be found.
  • In addition I've fixed the fixture command which raised an error for null.json. BTW. did you know that if the fixture contains following key in the returned object __error then cy.fixture throws an error :) ?

Additional details

  • Why was this change necessary?
    To provide better error message in case of missing fixture or problem with parsing

  • What is affected by this change?
    cy.route calls cy.fixture if response meets criteria of fixture shortcut fx: | fixture:. With this additional check we can raise an error even before HTTP request is sent.

How has the user experience changed?

If fixture file doesn't exists, or there is a problem with fixture, cy.route will raise an error.

Before:
image

Screen Shot 2020-07-17 at 1 16 51 PM

Now:
image

PR Tasks

  • Have tests been added/updated?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 14, 2020

Thanks for taking the time to open a PR!

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

@przemuh There's a failure with this implementation when run through our cypress-example-kitchensink repo. https://circleci.com/gh/cypress-io/cypress/395839

You should be able to clone the repo and run it in your branch with yarn start, add the project and see the failure from the files spec. Can you track down what introduced this failure?

Screen Shot 2020-07-16 at 11 42 30 AM

@przemuh
Copy link
Contributor Author

przemuh commented Jul 16, 2020

@jennifer-shehane Please check it now, it should be ok :)

The problem was in waiting command. After adding additional wrap with fixutre the name of the command is no longer route. That's why I've added additional check if subject of the command has a prop. To be honest I am not sure about this solution and I would be more than happy if you could double check it :)

@przemuh przemuh force-pushed the issue-7818 branch 2 times, most recently from 6cfe30f to 432cd31 Compare July 16, 2020 09:39
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

This null.json fixture should have already worked per #5562. But weirdly enough, it seems that we only fixed when this it's passed via fx: there: https://github.com/cypress-io/cypress/blob/develop/packages/driver/cypress/integration/commands/xhr_spec.js#L1870:L1870

I opened an issue to detail the null.json error here: #8010

packages/driver/cypress/integration/commands/xhr_spec.js Outdated Show resolved Hide resolved
@jennifer-shehane jennifer-shehane dismissed their stale review July 17, 2020 07:11

Dismissing my previous review for more thorough code review

Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

super, tests were added, so that's good. I just need an answer to my question for

return cy.fixture(options.response.replace(fixturesRe, '')).then(() => route())

@jennifer-shehane
Copy link
Member

Hey @przemuh, there were some requests for changes. It should be good to go after those are addressed. Do you have time to address them?

@przemuh
Copy link
Contributor Author

przemuh commented Jul 23, 2020

Hey @jennifer-shehane. This week I am on vacations🏖 without access to my computer...I will be more than happy to address all comments but around Sunday evening CET. I hope that it will not be a problem 😅

przemuh pushed a commit to przemuh/cypress that referenced this pull request Jul 27, 2020
@przemuh przemuh changed the title Fix: cy.route swallows the error about missing fixture #7818 fix: cy.route swallows the error about missing fixture #7818 Jul 27, 2020
Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

super, I think this is fine now

@bahmutov bahmutov merged commit dbe88da into cypress-io:develop Jul 27, 2020
@jennifer-shehane
Copy link
Member

I've identified that this PR introduced a regression - where the fixture files take longer to load, especially at large fixture file sizes, sometimes timing out. Detailed here: #8181

@przemuh
Copy link
Contributor Author

przemuh commented Aug 7, 2020

@jennifer-shehane I am really sorry about that :( I hope you will forgive me ;)

Here is a pull request with fix/revert: #8215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants