Files
cypress/packages/server
Chris Breiding e93e6ae0b4 Validate plugin event registration (#5356)
* Turn exception message into something human readable

* Pass ipc as parameter to invoke function

* Creating file to validate event name and handler

* Creating tests to validate_event

* Remove ipc from invoke parameter

* Removing ipc parameter being passed to validateEvent

* convert spec to js

* increase line-height for plugins error message

* refactor error messages and implementation

* fix race condition where async error in plugins file could hang run

a quick async error at the root of the plugins file had the potential to hang the run because the ‘exitEarlyWithErr’ listener was registered later than that error was emitted

this enables that error to be tracked so we can properly exit at the appropriate time

it also refactors run.js to not rely on an event emitted on the project and instead passes through an onError handler, which makes more sense since the event was only used in run.js (except for one case). it also makes for easier unit testing

* fix missing reference

* fix duplicate reference

* fix args being passed in incorrectly

* fix way args were handled in server.open

* fix exit early implementation

* fix duplicate logging

* fix unit test

* update snapshot

* fix missing reference

* add e2e test to cover plugin registration validation

* clean up after merge

* add back snapshot

* fix e2e tests

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
2020-03-05 16:00:42 -05:00
..
2020-02-26 15:53:43 -05:00

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 lerna run build-prod --scope @packages/server --stream
  • 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.coffee
## 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.coffee
## 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.coffee
## or
yarn test-e2e 1_async ## shorthand, uses globbing to find spec

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.coffee
SNAPSHOT_UPDATE=1 yarn test test/integration/cli_spec.coffee
SNAPSHOT_UPDATE=1 yarn test-e2e 1_async