Files
cypress/packages/server
Zach Bloomquist b0378dc04e Refactor proxy into own package, implement middleware pattern (#5136)
* renames

* Refactor proxy into own package, implement middleware pattern

don't need these mocha opts anymore

fix test

no more zunder

READMEs

fix test

* pass request by reference

* fix cors path

* Move replace_stream to proxy, concat-stream util in network

* Pin dependency versions

* Revert addDefaultPort behavior

* Add READMEs for proxy, network

* Update README.md

* eslint --fix

* set to null not undefined

* use delete and bump node types

* import cors from package now

* parse-domain@2.3.4

* proxy package needs common-tags

* move pumpify dep

* load through where it's needed, remove unused passthru_stream

* remove unneeded getbuffer call


Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
2019-11-27 19:16:15 -05:00
..
2019-03-31 23:39:10 -04: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.

Installing

The server's dependencies can be installed with:

cd packages/server
npm install

Developing

To run Cypress:

npm start ## boots the entire Cypress application

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.

Testing

  • npm run test-unit executes unit tests in test/unit
  • npm run test-integration executes integration tests in test/integration
  • npm run test-performance executes performance tests in test/performance
  • npm run test-e2e executes the large (slow) end to end tests in test/e2e

Each of these tasks can run in "watch" mode by appending -watch to the task:

npm run test-unit-watch

Because of the large number of dependencies of the server, it's much more performant to run a single individual test.

## runs only this one test file
npm run test ./test/unit/api_spec.coffee

## works for integration tests
npm run test ./test/integration/server_spec.coffee

You can also run a single test in watch mode.

## runs and watches only this one test file
npm run test-watch ./test/unit/api_spec.coffee

To run an individual e2e test:

You must build all packages before running the E2E tests. Run npm run build or npm run watch in the project root to accomplish this.

## runs tests that match "base_url"
npm run test-e2e -- --spec base_url

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

To update snapshots, see snap-shot-it instructions: https://github.com/bahmutov/snap-shot-it#advanced-use