Files
cypress/packages/server

Cypress App Circle CI

First Time Installs

npm install -g bower

Development

## Install project dependencies
npm install
## Watch all project files and build as necessary
npm run watch

Now, you have a few options to boot Cypress:

  1. Boot the Desktop Application in GUI mode.
  2. Run a project directly from the command line.
  3. Run a project headlessly.

1. GUI Mode

## this will boot the desktop app and
## display the 'cy' in your tray
npm start

Code changes which are applied instantly:

  • web app
  • driver

Code changes which require you to restart the running process:

  • server

When running in GUI mode you'll notice you may get a warning in your console: The local API server isn't running in development. This may cause problems running the GUI.

To avoid this warning make sure you start your API server.

## Start the API Server
cd cypress-api
npm start

2. Run project directly without GUI

## boot a specific project
npm run server -- --run-project <path-to-the-project-you-want-to-test>

You should see nodemon watching all of your files.

Code changes are applied instantly:

  • web app
  • driver
  • server

3. Run project headlessly

## boot a specific project
npm start -- --run-project <path-to-the-project-you-want-to-test>

You will see Cypress run all the tests headlessly and you'll see output in your console.

Testing the Driver

To run driver tests:

  • Navigate to the directory where the cypress-app project is on your computer.
  • Run the following commands:
gulp test

Navigate to http://localhost:3500

Debugging

Using debug module under namespace cypress:server. There are a few places where low-level events are also written, for example cypress:server:file. To see debug messages

DEBUG=cypress:server npm start ...

Deploying

npm run deploy

Releasing

npm run release

Rolling back

npm run release -- --version 0.9.6

If the user just updated their old app will be in their trash bin. They could always delete the new app and "put back" their trashed app.

Manually Completing An Update

This will manually complete an update given you have the new app downloaded and unzipped (which is the source), and you have the existing app (the destination).

This will copy the new (source) app to the existing (desination) app, and trash the existing (destination) app first.

open <path-to-new-cypress.app> --args --app-path <path-to-existing-app-path> --exec-path <path-to-existing-exec-path> --updating

Real example with paths:

open ~/Desktop/cypress.app --args --app-path /Users/bmann/Dev/cypress-app/build/0.5.8/osx64/cypress.app --exec-path /Users/bmann/Dev/cypress-app/build/0.5.8/osx64/cypress.app --updating

Remote Server Communication

To Connect

Remote servers need to connect to the web socket server:

In my node.js adapter, the remote server with this:

socket = require("socket.io-client")("http://localhost:2020", {path: "/__socket.io"})

Connecting to the remote room

Upon connecting to the websocket server you'll need to request to be put in the remote room. This allows the websocket server to know you're listening to requests.

To do that, emit a remote:connected message.

socket.emit("remote:connected")

You are now connected properly and ready to receive messages.

How messages are passed in and out

Client requests a message:

// passes in a message and optionally some JSON data
cy.message("create:user", {some: "data"})

Desktop App requests message from remote server:

// an unique guid ID is generated for this message
// and the desktop app broadcasts the 'remote:request' event
// and passes the ID, message, and optional data params
io.emit("remote:request", "123-a-guid-as-an-id", "create:user", {some: "data"})

Remote server responds:

// the remote server performs the work as per the message implementation
// and when its done it sends back a remote:response message
// and passes back the same GUID ID, as well as the new JSON response data
socket.emit("remote:response", "123-a-guid-as-an-id", {a: "new response data obj"})

Debugging Linux (Desktop)

  • vagrant halt
  • Modify Vagrantfile, comment out vm.box and uncomment vm.define desktop
  • vagrant up
  • .vagrant/ssh can be edited in sublime and takes effect immediately
  • Open terminal on the desktop
  • cd /cypress_app
  • npm i
  • Open new tab: npm run watch
  • node_modules/.bin/nw .

Catalog of Events

Order of Runnable Events

Event From To Description
restart:test:run Runner Anyone when cypress has been told to 're-run' and before iframes have been loaded. typically seen after a test change or the 'restart tests' button has been clicked
before:run Runner Anyone before run has started but after iframes have loaded
before:add Runner Anyone before any tests have been added to the UI
suite:add Runner Anyone when a suite should be added to the UI
test:add Runner Anyone when a test should be added to the UI
after:add Runner Anyone when all runnables have been added to the UI
runnables:ready Runner Anyone when all runnables have been reduced to basic objects
mocha:start Mocha Cypress when mocha runner triggers its 'start' event
suite:start Mocha Cypress when mocha runner fires its 'suite' event
test:before:run Cypress Anyone before any code has run for a particular test
test:before:hooks Cypress Cypress before any hooks for a test have started
hook:start Mocha Cypress when mocha runner fires its 'hook' event
test:start Mocha Cypress when mocha runner fires its 'test' event
suite:end Mocha Cypress when mocha runner fires its 'suite end' event
hook:end Mocha Cypress when mocha runner fires its 'hook end' event
mocha:pass Mocha Cypress when mocha runner fires its 'pass' event
mocha:pending Mocha Cypress when mocha runner fires its 'pending' event
mocha:fail Mocha Cypress when mocha runner fires its 'fail' event
test:end Mocha Cypress when mocha runner fires its 'test end' event
test:results:ready Runner Anyone when we receive the 'test:end' event
test:after:hooks Cypress Cypress after all hooks have run for a test
test:after:run Cypress Anyone after any code has run for a test
mocha:end Mocha Cypress when mocha runner fires its 'end' event
after:run Runner Anyone after run has finished

Command Events

Event From To Description
log:add Cypress Runner when log entries have been added (commands / routes / spies)
log:state:changed Cypress Runner when an existing logs state or attributes have changed

Request Events

Event From To Description
get:cookies Cypress Runner when cookies are being requested
get:cookie Cypress Runner when a cookie is being requested
set:cookie Cypress Runner when setting cookie is being requested
clear:cookie Cypress Runner when clearing a cookie is being requested
clear:cookies Cypress Runner when clearing cookies is being requested
message Cypress Runner when a msg is being requested
fixture Cypress Runner when a fixture is being requested
request Cypress Runner when a request is being requested
exec Cypress Runner when exec is being requested
paused Cypress Runner when pausing is being requested

AUT Events

Event From To Description
url:changed Cypress Anyone when aut app url is changed
page:loading Cypress Anyone when aut app is currently loading a page
viewport Cypress Anyone when viewport has changed

Server Sent Events

Event From To Description
watched:file:changed Server Runner when user has changed local spec file
automation:push:message Server Runner when automation server has sent a message