language: node_js

node_js:
  - 5.3

install:
  - npm install

  ## install the Cypress CLI Tools
  ## which gives us access to the
  ## `cypress` command used below
  - npm install -g cypress-cli

before_script:
  ## runs the 'start' script which
  ## boots our local app server on port 8080
  ## which cypress expects to be running
  ## -----------------------------------
  ## the '-- --silent' passes arguments
  ## to http-server which silences its output
  ## else our travis logs would be cluttered
  ## with output from HTTP requests
  ## https://docs.npmjs.com/cli/start
  ## https://github.com/indexzero/http-server
  ## ---------------------------------------
  ## we use the '&' ampersand which tells
  ## travis to run this process in the background
  ## else it would block execution and hang travis
  - npm start -- --silent &

script:
  ## now run cypress in CI mode
  ## which runs all of the tests
  ## and uses the CYPRESS_API_KEY
  ## environment var by default
  ## which you need to configure
  ## on Travis CI behind the scenes
  - cypress ci

  ## alternatively we could specify
  ## a specific secret key to use
  ## like this without having to
  ## configure anything in Travis CI:
  ## - cypress ci 703b33d9-a00e-4c66-90c2-40efc0fee2c6