Files
cypress/system-tests
Ryan Manuel df047b0a42 feat: cy.prompt experimental command [Feature Flagged] (#31752)
* Create cy-prompt-development.md

* chore: cy prompt infrastructure (#31748)

* feat: cy prompt infrastructure

* refactor and add tests

* refactor

* rename experimental config

* prompt

* fix test

* Update cy-prompt-development.md

* Update cy-prompt-development.md

* PR comments

* Update packages/server/lib/cloud/api/cy-prompt/get_cy_prompt_bundle.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* PR comments

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix test

* Delete packages/server/lib/cloud/StudioLifecycleManager.ts

* Delete packages/server/test/unit/cloud/StudioLifecycleManager_spec.ts

* chore: add cdp connection to cy prompt (#31806)

* chore: add cdp connection to cy prompt

* minor fix

* fix type build

* try to fix build

* Update packages/server/lib/browsers/browser-cri-client.ts

Co-authored-by: Bill Glesias <bglesias@gmail.com>

* Update packages/server/lib/browsers/browser-cri-client.ts

Co-authored-by: Bill Glesias <bglesias@gmail.com>

* do not support prompt in firefox or webkit

* rework timing of lifecycle

* refactor

* fix tests

* troubleshooting

* troubleshooting

* fix tests

* additional troubleshooting

* additional troubleshooting

* additional troubleshooting

* attempt to fix build

* add back

* debugging

* debugging

* debugging

* debugging

* clean up

* fix unit tests

* rework

---------

Co-authored-by: Bill Glesias <bglesias@gmail.com>

* chore: create infrastructure to support backend function in cy.prompt (#31803)

* chore: add promptBackend as an additional Cypress-attached function

* Update packages/app/src/runner/event-manager.ts

* update types

* fix types

* fix spacing

* refactor

* additional refactor

* fix type build

* fix build

* refactor

* reword messages

* fix

* debugging

* undo debugging

* PR comment

* fix tests

* fix tests

* fix tests

* fix test

* chore: add watcher for cy-prompt development (#31810)

* chore: add watcher for cy-prompt development

* test caching

* fix types

* chore: turn on beta deployments for cy-prompt

* internal: (cy.prompt) handle errors better in the command definition (#31835)

* internal: (cy.prompt) handle errors better in the command definition

* internal: (cy.prompt) add timeout and handle loading errors more cleanly

* add process environment variable

* clean up test

* update JSDoc

* chore: handle errors (#31854)

* chore: handle errors

* Fix ts, add test

* Fix error title

* Fix ts

* Fix ts

* chores: (cy.prompt) refactor routing to support both app and driver (#31891)

* chore: Share error utils with the cloud (#31887)

* share error utils with cloud

* additional rework

* Fix command, add isOpenMode

* Add / fix test

* fix ts

---------

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* internal: (cy.prompt) add infrastructure to support a Get Code modal (#31904)

* chore: (cy.prompt) add infrastructure to support a Get Code modal

* fix tests

* fix code paths

* Update eject button styles

* handle errors

* update types

* Update packages/server/lib/socket-base.ts

* Fix cy test

* update readme

---------

Co-authored-by: estrada9166 <estrada9166@gmail.com>

* chore: (cy.prompt) refactor getTestsState to take a runnable id (#31965)

* chore: (cy.prompt) refactor getTestsState to take a runnable id

* fix tests

* minor tweak

* chore: (cy.prompt) add manifest for all of the cloud delivered files (#31922)

* chore: (cy.prompt) add manifest for all of the cloud delivered files

* fix tests and remove environment variables

* update strategy

* fix build

* rework

* require manifest

* clean up

* refactor

* refactor

* Update packages/server/lib/cloud/cy-prompt/CyPromptLifecycleManager.ts

Co-authored-by: Matt Schile <mschile@cypress.io>

* fix test

---------

Co-authored-by: Matt Schile <mschile@cypress.io>

* feat: add cy prompt more info needed modal (WIP) (#31970)

* feat: add cy prompt more info needed modal

* Reset promptStore

* additional things exposed for more info

* rework

* fix tests

* fix build

* fix types

* fix types

* Update packages/app/src/runner/event-manager.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* reefactor

* chore: (cy.prompt) rework the file save lifecycle

* rework types

* add unit tests

---------

Co-authored-by: estrada9166 <estrada9166@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: (cy.prompt) ensure that we do not attach a vue ref to the react root in the cy.prompt modals (#32011)

* fix: (studio) ensure that we do not attach a vue ref to the react root in the studio panel

* fix test

* chore: Handle cy-prompt error to the cloud (#32009)

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* chore: display prompt error message (#32016)

* add createCloudRequest to cloudApi, handle errors during createCyPromptServer

* render the get code button on failure

* chore: update types

* chore: move CT and browser error to cloud (#32077)

* feat: (cy.prompt) give cy.prompt access to recording information (#32110)

* feat: (cy.prompt) give cy.prompt access to recording information

* undo bad refactor

* undo bad refactor

* undo bad refactor

* rename

* fix typo

* Update packages/server/test/unit/modes/record_spec.js

* Update packages/server/test/unit/modes/record_spec.js

* Update packages/server/test/unit/modes/record_spec.js

* Update packages/server/test/unit/modes/record_spec.js

* Update packages/server/test/unit/modes/record_spec.js

* Update cy-prompt-development.md

* Update cy-prompt-development.md

* Update cy-prompt-development.md

* chore: add CYPRESS_INTERNAL_SIMULATE_OPEN_MODE to simulate running Cypress tests in open mode (#32114)

* chore: (cy.prompt) ensure to strip out paths from all data when reporting errors in prompt (#32134)

* fix: (cy.prompt) ensure to strip out paths from all data when reporting errors in prompt

* refactor

* update tests

* fix logic error with protocol

* add event manager to get code

* Apply suggestions from code review

* fix: (cy.prompt) improve the get project options performance by running promises in parallel (#32196)

* fix: (cy.prompt) improve the get project options performance by running promises in parallel

* add awaits in test

* bump cache

* Update packages/server/lib/cloud/studio/StudioLifecycleManager.ts

* fix build

* chore: cleanup

* blank

* Update trigger-publish-binary-pipeline.js

* Update packages/server/test/unit/socket_spec.js

* get rid of environment variable

* fix: (cy.prompt) ensure to reset the prompt state when the event manager is torn down (indicating that we're no longer on the runner page) (#32301)

* fix: (cy.prompt) ensure to reset the prompt state when the event manager is torn down (indicating that we're no longer on the runner page)

* move test

* fix lint issue

* feat: (cy.prompt) introduce the concept of log collapse state being open/closed by default (#32262)

* feat: (cy.prompt) introduce the concept of logs' collapse state being open/closed by default

* update tests

* rename

* PR comments

* fix test due to bad merge of develop

* chore: Only allow experimentalPromptCommand within e2e config (#32435)

* chore: Only allow experimentalPromptCommand within e2e config

* Fix config

* Update tests

* Update test, update types

* Fix test and types

* fix tests

* Add types

* Update cli/types/cypress.d.ts

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

---------

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* Update workflows.yml

* Add optional cyPromptManagerPromise property

* Implement error handling in CyPromptManager

Added a new method to handle errors uniformly in CyPromptManager.

* Fix indentation in socket_spec.js

* fix: (cy.prompt) handle when the prompt is executed by in CT or when the experiment is not enabled (#32470)

* fix: (cy.prompt) handle when the prompt is executed by in CT or when the experiment is not enabled

* Update packages/driver/cypress/e2e/commands/prompt/prompt.cy.ts

* Update packages/driver/cypress/e2e/commands/prompt/prompt.cy.ts

* update name of errors

* Bump cache version to 9-15-2025

* update yarn.lock

* fixes

* fix snapshot

* fix snapshot

* internal: fix get code button to be purple with correct margin (#32504)

* feat: (cy.prompt) update the types of prompt (#32529)

* fix: move currentMoreInfoNeededModalInfo.onCancel to onClose (#32559)

* internal: (cy.prompt) various improvements to error messages and time outs (#32582)

* internal: (cy.prompt) various improvements to error messages and timeouts

* fix test

* remove dead code

* Update packages/driver/src/cy/commands/prompt/index.ts

* update prompt experiment description

* fix build

* fix tests

* fix tests

* fix test

* update error message

* Update packages/server/lib/experiments.ts

Co-authored-by: Tim Griesser <tgriesser10@gmail.com>

---------

Co-authored-by: Tim Griesser <tgriesser10@gmail.com>

* internal: (cy.prompt) ensure that get code can properly work with prompts in cy.origin (#32596)

* internal: (cy.prompt) ensure that get code can properly work with prompts in cy.origin

* additional tests

* additional tests

* Apply suggestions from code review

* code review comment

* fix merge

* fix merge

* Update packages/data-context/graphql/schemaTypes/index.ts

* update workflow

* blank

* persist binaries

* chore: display custom link title (#32567)

* chore: display custom link title

* Add test

* Pass docs as second argument of the error

* Revert changes

* Use openExternal for links

---------

Co-authored-by: Jennifer Shehane <jennifer@cypress.io>

* update

* internal: (cy.prompt) do not retry on cert failures (#32624)

* internal: (cy.prompt) do not retry on cert failures

* tests and clean up

* additional cleanup and add error message for prompt

* fix unit tests

* Update report_studio_error.ts

* Update packages/network/lib/agent.ts

* cursor comment

* fix build

* fix build

* fix test

* fix build

* fix build

* fix build

* fix build

* fix build

* revert

* Update packages/driver/src/cypress/error_messages.ts

* Update packages/driver/cypress/e2e/commands/prompt/prompt-initialization-error.cy.ts

* fix build

* cursor comment

* add changelog entry

* clean up

* Update packages/app/src/store/prompt-store.ts

* Bump cache version to 10-3-2025

Updated cache version to trigger CI cache recreation.

* Revise CHANGELOG for new features and fixes

Updated changelog with new features and bug fixes.

* index on feat/cy-prompt: 3cbcf6c336 Bump cache version to 10-3-2025

* index on feat/cy-prompt: 3cbcf6c336 Bump cache version to 10-3-2025

* index on feat/cy-prompt: 3cbcf6c336 Bump cache version to 10-3-2025

* blank

* fix build

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Bill Glesias <bglesias@gmail.com>
Co-authored-by: Alejandro Estrada <estrada9166@gmail.com>
Co-authored-by: Matt Schile <mschile@cypress.io>
Co-authored-by: Tim Griesser <tgriesser10@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
2025-10-04 09:01:00 -05:00
..

@tooling/system-tests

This package contains Cypress's suite of system tests.

These tests launch the Cypress server process for each test and run different specs and projects under specific environment conditions, to get tests that can be as close to "real world" as possible.

These tests run in CI in Electron, Chrome, Firefox, and WebKit under the system-tests job family.

Running System Tests

yarn test-system # runs all tests
## or use globbing to find spec in folders as defined in "glob-in-dir" param in package.json
yarn test-system screenshot*element # runs screenshot_element_capture_spec.js
yarn test-system screenshot # runs screenshot_element_capture_spec.js, screenshot_fullpage_capture_spec.js, ..., etc.

To keep the browser open after a spec run (for easier debugging and iterating on specs), you can pass the --no-exit flag to the test command. Live reloading due to spec changes should also work:

yarn test-system go_spec.js --browser chrome --no-exit

To debug the Cypress process under test, you can pass --cypress-inspect-brk:

yarn test-system go_spec.js --browser chrome --no-exit --cypress-inspect-brk

Developing Tests

System tests cover the entire Cypress run, so they are good for testing features that do not fit into a normal integration or unit test. However, they do take more resources to run, so consider carefully if you really need to write a system test, or if you could achieve 100% coverage via an integration or unit test instead.

There are two parts to a system test:

  1. A test written using the systemTests Mocha wrapper that lives in ./test, and
  2. A matching Cypress test project that lives in the ./projects directory.

For example, if you initialized a new project in ./projects/my-new-project, and you wanted to assert that 2 tests fail and take a snapshot of the stdout, you'd write a test like this:

// ./test/my-new-project.spec.ts
import systemTests from '../lib/system-tests'
import Fixtures from '../lib/fixtures'

describe('my new project', () => {
    // scaffold projects
    systemTests.setup()

    systemTests.it('fails as expected', {
        project: 'my-new-project',
        snapshot: true,
        spec: '*',
        expectedExitCode: 2
    })
})

From here, you could run this test with yarn test my-new-project.

There are many more options available for systemTests.it and systemTests.setup. You can massage the stdout, do pre-run tasks, set up HTTP/S servers, and more. Explore the typedocs in ./lib/system-tests for more information.

These tests run in the system-tests-* CI jobs.

Reusable Project Fixtures

In some situations, we want to test the same cypress project against multiple node_modules configurations. This is very common in component testing, where we want to ensure that the cypress/react package is compatible with different versions of React, or ensure that the cypress/webpack-dev-server is compatible with different versions of webpack.

The project-fixtures directory helps us here. Rather than duplicating the same set of files and needing to update in multiple places, we can specify a Cypress project in a folder, and if the project's package.json specifies a:

"projectFixtureDirectory": "$PROJECT_FIXTURE_FOLDER"`

We will automatically copy the contents of the project-fixtures folder into the project just after it has been scaffolded.

See the package.json for the webpack5_wds5-react package as an example of this pattern, and the webpack-dev-server react tests as an example use.

Developing Docker-based tests against built binary

Specs in the ./test directory are run against an unbuilt Cypress App. They don't test cypress NPM package installation or other prod app behavior. This is done so that they can run as fast as possible in CI, without waiting for a full build of the Cypress App.

Specs in ./test-binary are run against the built Cypress App. They also run inside of their own Docker containers to give a blank slate environment for Cypress to run in. Before each test, the prod CLI is npm installed along with the built Cypress .zip, and real cypress run commands are used to run the tests. There should be no functional difference between running a project in these tests and running real prod Cypress inside of Docker in CI.

The purpose of these tests is to test things that we normally can't inside of regular system-tests, such as testing Cypress with different Node versions, with/without Xvfb, or inside of different operating system versions.

An example of using dockerImage and withBinary to write a binary system test:

// ./test-binary/node-versions.spec.ts
import systemTests from '../lib/system-tests'
import Fixtures from '../lib/fixtures'

describe('node versions', () => {
    systemTests.it('runs in node 12', {
        dockerImage: 'cypress:node/12',
        project: 'todos',
        withBinary: true,
    })
})

Running yarn test node-versions would spin up a local Docker container for cypress:node/12, install Cypress from ../cypress.zip and ../cli/build, and then call the regular cypress run command within the container. Other options for systemTests.it such as onRun and expectedExitCode still function normally.

These tests run in the binary-system-tests CI job.

Updating Snapshots

Prepend SNAPSHOT_UPDATE=1 to any test command. See snap-shot-it instructions for more info.

SNAPSHOT_UPDATE=1 yarn test go_spec

If you are on a Retina device, you may get mismatching screenshot dimensions when updating snapshots. To resolve this, you can set the SNAPSHOT_BROWSER environment variable to chrome when you update the snapshots.

Test Projects

Every folder in ./projects represents a self-contained Cypress project. When you pass the project property to systemTests.it or systemTests.exec, Cypress launches using this project.

If a test project has a package.json file, the systemTests.exec helper will attempt to install the correct node_modules by running yarn install or npm install (depending on which lockfile is present) against the project. This is cached in CI and locally to speed up test times.

systemTests.exec copies the project directory to a temporary folder outside of the monorepo root. This means that temporary projects will not inherit the node_modules from this package or the monorepo. So, you must add the dependencies required for your project in dependencies or devDependencies.

The exception is some commonly used packages that are scaffolded for all projects, like lodash and debug. You can see the list by looking at scaffoldCommonNodeModules in ./lib/fixtures.ts These packages do not need to be added to a test project's package.json.

You can also set special properties in a test project's package.json to influence the helper's behavior when running yarn or npm:

package.json Property Name Type Description
_cySkipDepInstall boolean If true, skip the automatic yarn install or npm install for this package, even though it has a package.json.
_cyYarnV311 boolean Run the yarn v3.1.1-style install command instead of yarn v1-style.
_cyRunScripts boolean By default, the automatic install will not run postinstall scripts. This option, if set, will cause postinstall scripts to run for this project.

Run yarn projects:yarn:install to run yarn install/npm install for all applicable projects.

Use the UPDATE_LOCK_FILE=1 environment variable with yarn test or yarn projects:yarn:install to allow the yarn.lock or package-lock.json to be updated and synced back to the monorepo from the temp dir.