cypress-io / cypress-example-kitchensink

This is an example app used to showcase Cypress.io testing.
https://example.cypress.io/
MIT License
1.2k stars 2.2k forks source link

cy.end() test from earlier versions fails against example.cypress.io/commands/misc #819

Closed MikeMcC399 closed 5 months ago

MikeMcC399 commented 5 months ago

Issue

cypress-example-kitchensink@2.0.5 causes scaffolded examples from cypress@13.7.1 to fail the cy.end() test. This test was removed from this repo, however earlier versions of Cypress still use this test.

cypress-example-kitchensink@2.0.5 which is published to https://example.cypress.io/ causes scaffolded tests set up from cypress@11.0.0 through to cypress@13.7.1 to fail in the spec cypress/e2e/2-advanced-examples/misc.cy.js.

The scaffolded test for .end() fails since .misc-table is no longer available on https://example.cypress.io/commands/misc

This is the failing test:

context('Misc', () => {
  beforeEach(() => {
    cy.visit('https://example.cypress.io/commands/misc')
  })
  it('.end() - end the command chain', () => {
    // https://on.cypress.io/end

    // cy.end is useful when you want to end a chain of commands
    // and force Cypress to re-query from the root element
    cy.get('.misc-table').within(() => {
      // ends the current chain and yields null
      cy.contains('Cheryl').click()
      //.end()

      // queries the entire table again
      cy.contains('Charles').click()
    })
  })
...

Steps to reproduce

Using cypress-example-kitchensink

On Ubuntu 22.04.4 LTS with Node.js 20.12.0 LTS

git clone --branch v2.0.5 https://github.com/cypress-io/cypress-example-kitchensink --depth 1 -- cy-example-2-0-5
cd cy-example-2-0-5
npm install
npm start

In a separate terminal window run Cypress tests with the earlier version 2.0.3:

git clone --branch v2.0.3 https://github.com/cypress-io/cypress-example-kitchensink --depth 1 -- cy-example-2-0-3
cd cy-example-2-0-3
npm install
npx cypress run --spec cypress/e2e/2-advanced-examples/misc.cy.js

Note failure

.end() - end the command chain

Using cypress@13.7.1

On Ubuntu 22.04.4 LTS with Node.js 20.12.0 LTS

mkdir cy-e2e-13-7-1
cd cy-e2e-13-7-1
git init
npm init -y
npm install cypress@13.7.1 -D -E
npx cypress open --e2e --browser electron

Select "Continue" Select "Scaffold example specs" Select "Okay, I got it!" Close Cypress Runner and Cypress Launchpad

npx cypress run --spec cypress/e2e/2-advanced-examples/misc.cy.js

Note failure

.end() - end the command chain

Log

  Misc
    1) .end() - end the command chain
    ✓ cy.exec() - execute a system command (314ms)
    ✓ cy.focused() - get the DOM element that has focus (361ms)
    ✓ cy.wrap() - wrap an object (125ms)
    Cypress.Screenshot
      ✓ cy.screenshot() - take a screenshot (861ms)
      ✓ Cypress.Screenshot.defaults() - change default config of screenshots (130ms)

  5 passing (8s)
  1 failing

  1) Misc
       .end() - end the command chain:
     AssertionError: Timed out retrying after 4000ms: Expected to find element: `.misc-table`, but never found it.
      at Context.eval (webpack://cypress-example-kitchensink/./cypress/e2e/2-advanced-examples/misc.cy.js:13:7)

Suggestion

Revert changes to

from PR https://github.com/cypress-io/cypress-example-kitchensink/pull/807 for backwards compatibility to scaffolded example specs which have been set up using Cypress 13.7.1 and earlier.

jennifer-shehane commented 5 months ago

Yah I think we should just add the misc-table back so that people's older scaffolded tests won't fail: https://github.com/cypress-io/cypress-example-kitchensink/pull/807/files#diff-dd7cc5e700fcd9390c4cfe9035e9eea6f5608c8b0d4be38820d4217a2b14e9bcL87

cypress-app-bot commented 5 months ago

:tada: This issue has been resolved in version 2.0.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket: