Files
cypress/packages/server/README.md
T
Jennifer Shehane fe937d3450 Display full specfile(s) in stdout during cypress run (#5120)
* Begin inserting newlines for long specfiles in results table of stdout

* clean up some decaff weirdness

* move newlines function into util

- call ‘formatPath’ on any area where the path could be too long and
needs to word wrap

* Clean up some styles, padding that does nothing - get specname closer to symbol by 1 pixel

* Commit new snapshot changes. Word wrapping, some spacing changes

* remove more padding that does functionally nothing

* Fix more of the extra unnecessary padding in 'Running' table

* Update other CLI snapshots to match new spacing

* Remove the error thrown when colWidths exceeds 100, I don't see this as necessary since we have snapshots covering the design of the columns.

* Update some snapshots I missed

* Add gaurd in newLine function in case there is no specfile name

* fix more snapshots

* Fix snapshot extra space

* forcibly enable colors in all e2e tests, and strip them back out of the snapshots

* Fix colors that got lost in stdout

* Update newlines function to use simpler ramda split + fix implementation to remove last newline

- write unit test for newlines function for easier refactoring in future

* iterating on fixing the weird column issues

* handle if str is undefined in newlines function

* Draw the tables at exact 100 width, taking into account padding and borders

- Calculate the actual width of the table column in order to add
newlines at that length
- Add newlines for the ‘Finished processing’ output of video file
- Add newlines for the ‘Screenshots’ output of screenshot paths

* remove .only

* Remove extra 1 char padding

* Remove color changes (separate PR for this)

* Replace project path with same num chars of X's

We were just replacing it with foo/bar/baz which would mess up the
alignment of the snapshots since it was removing chars

* If we are running with a CYPRESS_ENV of 'test', replace the cwd

- Replace the current working directory if we’re running withing
Cypress so that our snapshots are consistent when run on diff machines.
- Ideally, I would have liked to have had a special ‘—fake-cwd-path’
flag so that we can override this later, but I couldn’t figure how to
pass that.

* Continue stripping the projectPath from snapshot output

- This is required because some messaging comes from outside of the
run.js file, so we still need to replace these paths in snapshot.

* Update snapshots to have correctly replaced cwd

* Update formatting of new Node Version path to properly return within our stdout tables

* remove tests for method that does not exist

- update the drawing of table columns to match the new logic - don’t
need weird spaces and padding right anymore.
- update snapshot to match

* Update snapshot for performance test that didn't previously run

* return empty string if no name passed (really just for weird edgecases in our own tests)

* Add instructions on how to run performance tests in server

* Update video processing and screenshot tables so they no longer use weird negative padding hack with ' ' border

* Update snapshots to reflect new table spacing

* Another snapshot update missed

* Accept 'FAKE_CWD_PATH' env var to replace it in the run

* Pad paren time to factor in extra whitespace

* Update snapshots to no longer have static 'acb123.mp4' for video names

- This was throwing off the table calculations.

* remove stripping screenshot dimensions + replace padStart with padEnd

* Update snapshots to instead user shorter form 'second' in order to account for shorter duration printing when it is 1 second

* Add correct padding for screenshot dimensions

* update perf spec

* Update performance snapshot

* remove unused 'stripAnsi' dep

* Fix merge conflict failure - didn't regenerate snapshot correctly last time.

* commit size of electron screenshot (fix incoming in another PR to avoid this)

* Correctly handle padding of node version so we don't have to rewrite this later.

* split out let & const assignments


Co-authored-by: Brian Mann <brian.mann86@gmail.com>
2019-10-21 11:21:34 -04:00

2.3 KiB

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:

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

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