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

cy.route swallows the error about missing fixture #7818

Closed
przemuh opened this issue Jun 25, 2020 · 4 comments · Fixed by #7983
Closed

cy.route swallows the error about missing fixture #7818

przemuh opened this issue Jun 25, 2020 · 4 comments · Fixed by #7983

Comments

@przemuh
Copy link
Contributor

@przemuh przemuh commented Jun 25, 2020

Current behavior:

When I use shortcut to load a fixture that doesn't exists

cy.route("/path", "fixture:myFileWithDifferentName")

I get an error:

CypressError: The following error originated from your application code, not from Cypress.

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.

https://on.cypress.io/uncaught-exception-from-applicationAnd in cy logger there is info that request has been stubbed but responded with `400` HTTP code:![stub](https://user-images.githubusercontent.com/3865478/85800408-33522480-b741-11ea-9d67-3c31046eeba9.png)Maybe related: https://github.com/cypress-io/cypress/issues/78 ?### Desired behavior:Error message should be the same as for `cy.fixture` command:```jscy.fixture("notExistingFixture");``````Error: A fixture file could not be found at any of the following paths:> cypress/fixtures/examplEFixture> cypress/fixtures/examplEFixture{{extension}}Cypress looked for these file extensions at the provided path:.json, .js, .coffee, .html, .txt, .csv, .png, .jpg, .jpeg, .gif, .tif, .tiff, .zip

Provide a path to an existing fixture file.


Screen:

![fixture](https://user-images.githubusercontent.com/3865478/85800502-609ed280-b741-11ea-932d-cf82d6772574.png)

### Test code to reproduce
You can read the full story on my blog:
https://przemuh.dev/en/blog/watch-out-for-fixtures-in-cypress

App to reproduce the issue (with caseSensitive name) on Linux:
https://github.com/przemuh/cypress-fixture-case

### Versions
4.9.0

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jun 26, 2020

Thanks for the thorough write up! I read the blog and agree that this error should be better.

@cypress-bot cypress-bot bot added the stage: proposal 💡 No work has been done of this issue label Jun 26, 2020
@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: proposal 💡 No work has been done of this issue labels Jun 26, 2020
przemuh pushed a commit to przemuh/cypress that referenced this issue Jul 14, 2020
@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] and removed stage: ready for work The issue is reproducible and in scope labels Jul 14, 2020
przemuh pushed a commit to przemuh/cypress that referenced this issue Jul 15, 2020
przemuh pushed a commit to przemuh/cypress that referenced this issue Jul 15, 2020
przemuh pushed a commit to przemuh/cypress that referenced this issue Jul 16, 2020
przemuh pushed a commit to przemuh/cypress that referenced this issue Jul 16, 2020
przemuh pushed a commit to przemuh/cypress that referenced this issue Jul 16, 2020
…e does not exist

- cy.route now tries to load a fixture before setting up the stub
- cy.wait needed to be changed
- onFixtureErrror now proper handles the error message
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress There is an open PR for this issue [WIP] labels Jul 16, 2020
@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jul 17, 2020

Full repro:

it('fails with application error', () => {
  cy.visit('https://example.cypress.io/commands/aliasing')
  cy.server()
  cy.route('GET', 'comments/*', 'fx:notExistingFixture').as('getComment')
  cy.get('.network-btn').click()
  cy.wait('@getComment').its('status').should('eq', 200)
})

it('fails correctly - fixutre not found', () => {
  cy.fixture("notExistingFixture")
})

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

@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] and removed stage: needs review The PR code is done & tested, needs review labels Jul 20, 2020
przemuh added a commit to przemuh/cypress that referenced this issue Jul 27, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress There is an open PR for this issue [WIP] labels Jul 27, 2020
@cypress-bot cypress-bot bot added the stage: pending release There is a closed PR for this issue label Jul 27, 2020
@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Jul 27, 2020
@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented Jul 27, 2020

The code for this is done in cypress-io/cypress#7983, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented Aug 3, 2020

Released in 4.12.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.12.0, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: pending release There is a closed PR for this issue label Aug 3, 2020
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants