# protractor-ci

> Easily run protactor using Travis CI and Sauce Labs.

Latest version **0.0.2-alpha6** (published 2014-11-12) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install protractor-ci
pnpm add protractor-ci
yarn add protractor-ci
bun add protractor-ci
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2-alpha6 |
| Published | 2014-11-12 |
| First published | 2014-11-03 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Lynn Dylan Hurley |
| Maintainers | lynndylanhurley |
| Keywords | E2E, protractor, sauce, labs, travis, ci, nock |

## Links

- npm: https://www.npmjs.com/package/protractor-ci
- Repository: https://github.com/lynndylanhurley/protractor-ci
- Issues: https://github.com/lynndylanhurley/protractor-ci/issues
- npm.io page: https://npm.io/package/protractor-ci

## Dependencies (10)

- [q](https://npm.io/package/q.md) ~1.0.1
- [fs](https://npm.io/package/fs.md) ~0.0.2
- [nock](https://npm.io/package/nock.md) ~0.48.2
- [path](https://npm.io/package/path.md) ~0.4.9
- [mkdirp](https://npm.io/package/mkdirp.md) ~0.5.0
- [request](https://npm.io/package/request.md) ~2.36.0
- [gulp-util](https://npm.io/package/gulp-util.md) ~3.0.1
- [protractor](https://npm.io/package/protractor.md) ~1.3.1
- [coffee-script](https://npm.io/package/coffee-script.md) ~1.8.0
- [sauce-connect-launcher](https://npm.io/package/sauce-connect-launcher.md) ~0.7.0

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 0.0.2-alpha6 (latest) — 2014-11-12
- 0.0.2-alpha5 — 2014-11-12
- 0.0.2-alpha4 — 2014-11-06
- 0.0.2-alpha3 — 2014-11-05
- 0.0.2-alpha2 — 2014-11-05
- 0.0.2-alpha1 — 2014-11-03
- 0.0.1 — 2014-11-03

## README

# Protractor CI

[![npm version](https://badge.fury.io/js/protractor-ci.svg)](http://badge.fury.io/js/protractor-ci)

# Warning

This project is **alpha** status. Use at your own risk.

# Goals

* Run E2E tests against all target browsers.
* Run E2E tests on Travis CI.
* Mock requests to external APIs (semi-automatically).

# Installation

~~~bash
npm install protractor-ci --save-dev
~~~

# Workflow

1. [Run E2E tests against locally against live dev API](#run-local-e2e-tests)
   This step records all external API requests for later playback.

2. [Verify test playback](#playback-e2e-tests)
   Uses the recorded mock requests from step 1.

3. [Run E2E tests against Sauce Labs](#playback-e2e-tests-using-saucelabs)
   Uses the recorded mock requests from step 1.

4. [Run E2E tests on Travis CI on deployment](#travis-ci-setup)
   Uses the recorded mock requests from step 1.

# Run Local E2E Tests

Define the task:

~~~javascript
var pXor = require('protractor-ci');

gulp.task('test:e2e:record', function(cb) {
  var opts = {
    nodeApp:   'test/app.js',
    nodeHost:  'localhost',
    nodePort:  7777,
    record:    true,
    mockFile:  'mocks/nock-mocks.json',
    specs: [
      'test/e2e/*.coffee'
    ]
  };

  pXor.e2e.testE2E(opts).then(function() { cb(); });
});
~~~

Run the task:

~~~bash
gulp test:e2e:record
~~~

# Playback E2E Tests

Define the task:

~~~javascript
var pXor = require('protractor-ci');

gulp.task('test:e2e:playback', function(cb) {
  var opts = {
    nodeApp:   'test/app.js',
    nodeHost:  'localhost',
    nodePort:  7777,
    playback:  true,
    mockFile:  'mocks/nock-mocks.json',
    specs: [
      'test/e2e/*.coffee'
    ]
  };

  pXor.e2e.testE2E(opts).then(function() { cb(); });
});
~~~

Run the task:

~~~bash
gulp test:e2e:playback
~~~

# Playback E2E Tests using SauceLabs

~~~javascript
var pXor = require('protractor-ci');

// define task to start sauce connect
gulp.task('start-sauce-connect', function(cb) {
  pXor.e2e.startSauceConnect().then(function() { cb(); });
});

// define test runner
gulp.task('test:e2e:ci', function(cb) {
  var opts = {
    nodeApp:   'test/app.js',
    nodeHost:  'localhost',
    nodePort:  7777,
    playback:  true,
    mockFile:  'mocks/nock-mocks.json',
    specs: [
      'test/e2e/*.coffee'
    ],
    browsers: [{
      browserName:         'chrome',
      build:               process.env.TRAVIS_BUILD_NUMBER,
      'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
    }, {
      browserName:         'firefox',
      build:               process.env.TRAVIS_BUILD_NUMBER,
      'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
    }, {
      browserName:         'safari',
      build:               process.env.TRAVIS_BUILD_NUMBER,
      'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
    }, {
      browserName:         'internet explorer',
      version:             11,
      build:               process.env.TRAVIS_BUILD_NUMBER,
      'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
    }, {
      browserName:         'internet explorer',
      version:             10,
      build:               process.env.TRAVIS_BUILD_NUMBER,
      'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
    }, {
      browserName:         'internet explorer',
      version:             9,
      build:               process.env.TRAVIS_BUILD_NUMBER,
      'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
    }, {
      browserName:         'internet explorer',
      version:             8,
      build:               process.env.TRAVIS_BUILD_NUMBER,
      'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
    }]
  };

  pXor.e2e.testE2E(opts).then(function() { cb() });
});

~~~

Now open two terminal windows.

In the first terminal:

~~~bash
gulp start-sauce-connect
~~~

Leave the terminal open. The task will let you know when it's ready to start the tests.

In the second terminal:

~~~bash
gulp test:e2e:ci
~~~

# Travis CI Setup

First follow [these instructions](https://docs.saucelabs.com/ci-integrations/travis-ci/).

Next, make sure the `before_install` and `addons` blocks exist in your `.travis.yml` file:

~~~yml
language: node_js
node_js:
- 'x.xx'

env:
  global:
  - secure: xxx
  - secure: yyy
  - NODE_ENV=travis

addons:
  sauce_connect: true

cache:
  directories:
    - node_modules

before_install:
- npm install
- node_modules/.bin/bower install --config.directory=path/to/test/server
~~~

The goal is to ensure that the dev server has everything it needs to be run by Travis. More steps may be required depending on your application.

Then, in your `package.json` file:

~~~javascript
{
  // ...
  "scripts": {
    "test": "gulp test:e2e:ci"
  },
  // ...
}
~~~

---
_Source: https://npm.io/package/protractor-ci · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
