Files
cypress/packages/server
Zach Panzarino 7d468d4e2c Split hooks and open hooks in ide from reporter (#7821)
* Add invocation details to hooks

* Add hooks to emitted root runnable

* Hook details model

* Progress on hook models

* Add commands to hook

* Fix display of hooks

* Display hooks in correct order

* (More) efficiently reorder hooks and display split numbers

* Open hook in IDE functionality

* Properly style button to open in IDE

* Add ability to open test body in IDE

* Fix hooks specs

* Runnables store tests

* Test model unit tests

* HookDetails -> HookProps

* Fix reporter integration tests

* Fix issue with after hook

* Update runner mocha tests

* Remove driver integration test that is no longer needed

* Update snapshot for server tests

* Add reporter integration tests for hooks

* Fix driver querying test

* Add runner test for hooks

* Update reporter hook tests to check for before all

* Fix before/after hook counts

* Fix runner test

* Fix issue with stack trace in ff and clean up mocha override

* Just incase someone names their test or support file common.js

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
2020-07-07 21:17:03 +06:30
..

Server

The server is the heart of the Cypress application. All of this code represents the node process running behind the browser application. This node process is responsible for:

  • Proxying every byte coming in and out of the browser
  • Performing and normalizing automation tasks for each browser
  • Coordinating and synchronizing state with the desktop-gui and driver packages
  • Performing node specific tasks on behalf of the driver
  • Instantiating and orchestrating nearly every other layer and package
  • Spinning up various static file and http servers
  • Communicating with our external API's
  • Recording videos of run
  • Managing mocha reporters
  • Managing 3rd party plugins

The driver and the server are the two most complex packages of Cypress.

Developing

To run the Cypress server:

## boots the entire Cypress application
yarn start

Since the server controls nearly every aspect of Cypress, after making changes you'll need to manually restart Cypress.

Since this is slow, it's better to drive your development with tests.

Building

Note: you should not ever need to build the .js files manually. @packages/ts provides require-time transpilation when in development.

yarn workspace @packages/server build-prod
  • yarn test-unit executes unit tests in test/unit
  • yarn test-integration executes integration tests in test/integration
  • yarn test-performance executes performance tests in test/performance
  • yarn test-e2e executes the large (slow) end to end tests in test/e2e

You can also use the test-watch command to rerun a test file whenever there is a change:

yarn test-watch /test/path/to/spec.js

When running e2e tests, some test projects output verbose logs. To see them run the test with DEBUG=cypress:e2e environment variable.

Running individual unit tests

yarn test <path/to/test>
yarn test test/unit/api_spec.js
## or
yarn test-unit api_spec ## shorthand, uses globbing to find spec

Running individual integration tests

yarn test <path/to/test>
yarn test test/integration/cli_spec.js
## or
yarn test-integration cli_spec ## shorthand, uses globbing to find spec

Running individual e2e tests

yarn test <path/to/test>
yarn test test/e2e/1_async_timeouts_spec.js
## or
yarn test-e2e 1_async ## shorthand, uses globbing to find spec

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 e2e test command. Live reloading due to spec changes should also work:

yarn test test/e2e/2_go_spec.js --browser chrome --no-exit

Updating snaphots

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

SNAPSHOT_UPDATE=1 yarn test test/unit/api_spec.js
SNAPSHOT_UPDATE=1 yarn test test/integration/cli_spec.js
SNAPSHOT_UPDATE=1 yarn test-e2e 1_async