Skip to content

Commit

Permalink
test(gatsby): Add buffer time to failing react 18 e2e tests (#35673)
Browse files Browse the repository at this point in the history
* Skip failing react 18 tests

* Instead of skipping, add buffer time after route change

* Add to third test
  • Loading branch information
imjoshin committed May 16, 2022
1 parent 7732447 commit 5d3bb53
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ describe(`Production build tests`, () => {

cy.getTestElement(`page2`).click().waitForRouteChange()

// add buffer time so that componentDidMount has time to be called after route change
cy.wait(1000)

// we expect 2 `componentDidMount` calls - 1 for initial page and 1 for second page
cy.lifecycleCallCount(`componentDidMount`).should(`equal`, 2)
cy.lifecycleCallCount(`render`).should(`equal`, 2)
Expand All @@ -14,6 +17,9 @@ describe(`Production build tests`, () => {

cy.getTestElement(`duplicated`).click().waitForRouteChange()

// add buffer time so that componentDidMount has time to be called after route change
cy.wait(1000)

// we expect 2 `componentDidMount` calls - 1 for initial page and 1 for duplicated page
cy.lifecycleCallCount(`componentDidMount`).should(`equal`, 2)
cy.lifecycleCallCount(`render`).should(`equal`, 2)
Expand All @@ -26,6 +32,9 @@ describe(`Production build tests`, () => {

cy.getTestElement(`/nested/foo`).click().waitForRouteChange()

// add buffer time so that componentDidMount has time to be called after route change
cy.wait(1000)

// we expect just 1 `componentDidMount` call, when navigating inside matchPath
cy.lifecycleCallCount(`componentDidMount`).should(`equal`, 1)
cy.lifecycleCallCount(`render`).should(`equal`, 3)
Expand Down

0 comments on commit 5d3bb53

Please sign in to comment.