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

Using apollo-client breaks the tests when run with electron #5044

Closed
nik-lampe opened this issue Aug 27, 2019 · 7 comments · Fixed by #4720
Closed

Using apollo-client breaks the tests when run with electron #5044

nik-lampe opened this issue Aug 27, 2019 · 7 comments · Fixed by #4720

Comments

@nik-lampe
Copy link

Current behavior:

I have an app that uses apollo for graphql queries. Then I wrote a test, that simply checks if all the links in my app work as expected.
This works fine when run in chrome, but when run in electron every other test fails with an
Uncaught Invariant Violation: Maximum update depth exceeded error.

Desired behavior:

Well... this should not happen, i guess :)

Steps to reproduce: (app code and test code)

I have stumbled across this in my production app, but I have recreated it with a minimal setup.

You can see it in action here:
https://github.com/nik-lampe/cypress-apollo-maximum-stack-error

It's just the sample app from apollo from here:
https://codesandbox.io/s/r5qp83z0yq

Together with a really simple test:


describe('Navigate through the page', () => {

  it(`Can visit /`, () => {
    cy.visit('/')
    cy.contains('PUPSTAGRAM').should('be.visible')
  })


  it(`Can visit /african/Z1gPiBt`, () => {
    cy.visit('/african/Z1gPiBt')
    cy.contains('african').should('be.visible')
  })

  it(`Can visit /airedale/ZNDtCU`, () => {
    cy.visit('/airedale/ZNDtCU')
    cy.contains('airedale').should('be.visible')
  })

})

Just run yarn, run the app with yarn start, and then run the test runner. Choose electron, and it fails. Use chrome and it's green.

Versions

{
"@apollo/react-hooks": "0.1.0-beta.11",
"apollo-boost": "0.4.3",
"cypress": "^3.4.1",
"graphql": "latest",
"react": "16.8.6",
"react-art": "16.3.2",
"react-dom": "16.8.6",
"react-native-web": "latest",
"react-router": "latest",
"react-router-dom": "latest",
"react-scripts": "1.1.0",
"recyclerlistview": "1.2.6"
}

MacOS Mojave 10.14.6

@mariana-mendes
Copy link

mariana-mendes commented Aug 29, 2019

Same issue here.
The first case works. However, on the second case it starts to fail with the same message. ( Uncaught Invariant Violation: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.)
My test:

describe('test name', () => {
  before(() => {
    cy.login()
  })
  beforeEach(() => cy.visit('/create'))
  it('first case', () => {
    cy.get(saveButton)
      .parent()
      .should('be.disabled')
  })

// starts to fail
  it('second case', () => {
    cy.get(collectionNameInput).then($element => {
      cy.wrap($element).type('Collection name')
    })

    cy.get(saveButton).then($saveButton => {
      cy.wrap($saveButton)
        .parent()
        .should('be.enabled')
    })
  })``` 

@flotwig
Copy link
Contributor

flotwig commented Aug 29, 2019

I can also reproduce this by running the example repo in Chrome 61, leading me to think it's a bug between Cypress, the bundled Chrome version (61), and apollo-client.

#4720 should fix this issue by upgrading the bundled Chrome to a modern version.

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Sep 12, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Sep 24, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 24, 2019

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

1 similar comment
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 24, 2019

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

@justinanastos
Copy link

Super psyched to see this update! I'd be happy to test a pre-release version 😃

Thank you @nik-lampe for reporting the issue and building a reproduction!

@flotwig
Copy link
Contributor

flotwig commented Oct 17, 2019

@justinanastos here's a link with instructions to download the latest prerelease: c141603#commitcomment-35551163

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants