-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Subject
API > Other Commands > end > Examples
Description
Current behavior
The following API example for cy.end()
as shown on the documentation site
cy.contains('User: Cheryl')
.click()
.end() // yields null
.contains('User: Charles')
.click() // contains looks for content in document now
fails to run. The error is:
The subject received was:
>
null
Desired behavior
API > Other Commands > end > Examples should provide an example of using cy.end()
which runs.
Test code to reproduce
git clone --branch cypress-end https://github.com/MikeMcC399/cypress-test-tiny
cd cypress-test-tiny
npm ci
npx cypress run
Cypress Version
First reported on Cypress version: 13.7.0
Also reproducible on Cypress 14.1.0
Node version
v20.11.1
v20.17.0
& v22.14.0
Operating System
Ubuntu 22.04.4
LTS
Debug Logs
npx cypress run
DevTools listening on ws://127.0.0.1:39575/devtools/browser/3ea597d9-3fde-48a0-89a0-017c62cd3205
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 13.7.0 │
│ Browser: Electron 118 (headless) │
│ Node Version: v20.11.1 (/home/mike/n/bin/node) │
│ Specs: 1 found (end.cy.js) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: end.cy.js (1 of 1)
End
1) .end() - according to docs site
0 passing (19s)
1 failing
1) End
.end() - according to docs site:
CypressError: Timed out retrying after 4000ms: `cy.contains()` failed because it requires a DOM element, window or document.
The subject received was:
> `null`
The previous command that ran was:
> `cy.end()`
at isElement (https://example.cypress.io/__cypress/runner/cypress_runner.js:145288:58)
at validateType (https://example.cypress.io/__cypress/runner/cypress_runner.js:145137:14)
at Object.isType (https://example.cypress.io/__cypress/runner/cypress_runner.js:145168:7)
at <unknown> (https://example.cypress.io/__cypress/runner/cypress_runner.js:132349:22)
at Object.subjectFn (https://example.cypress.io/__cypress/runner/cypress_runner.js:144150:16)
at $Cy.verifyUpcomingAssertions (https://example.cypress.io/__cypress/runner/cypress_runner.js:143494:31)
at onRetry (https://example.cypress.io/__cypress/runner/cypress_runner.js:144141:15)
at tryCatcher (https://example.cypress.io/__cypress/runner/cypress_runner.js:1807:23)
at Promise.attempt.Promise.try (https://example.cypress.io/__cypress/runner/cypress_runner.js:4315:29)
at whenStable (https://example.cypress.io/__cypress/runner/cypress_runner.js:144028:68)
at <unknown> (https://example.cypress.io/__cypress/runner/cypress_runner.js:143969:14)
at tryCatcher (https://example.cypress.io/__cypress/runner/cypress_runner.js:1807:23)
at Promise._settlePromiseFromHandler (https://example.cypress.io/__cypress/runner/cypress_runner.js:1519:31)
at Promise._settlePromise (https://example.cypress.io/__cypress/runner/cypress_runner.js:1576:18)
at Promise._settlePromise0 (https://example.cypress.io/__cypress/runner/cypress_runner.js:1621:10)
at Promise._settlePromises (https://example.cypress.io/__cypress/runner/cypress_runner.js:1701:18)
at Promise._fulfill (https://example.cypress.io/__cypress/runner/cypress_runner.js:1645:18)
at <unknown> (https://example.cypress.io/__cypress/runner/cypress_runner.js:5450:46)
From Your Spec Code:
at Context.eval (webpack://cypress-test-tiny/./cypress/e2e/end.cy.js:18:9)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: false │
│ Duration: 19 seconds │
│ Spec Ran: end.cy.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Screenshots)
- /home/mike/github/cypress-io/cypress-test-tiny/cypress/screenshots/end.cy.js/End (1280x720)
-- .end() - according to docs site (failed).png
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ end.cy.js 00:19 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) 00:19 1 - 1 - -