Giter Site home page Giter Site logo

gulp-protractor's Introduction

gulp-protractor NPM version Build Status Dependency Status

Run your angular protractor tests with gulp

Usage

First, install gulp-protractor AND protractor as a development dependency:

npm install --save-dev gulp-protractor protractor

Then, add it to your gulpfile.js:

var protractor = require("gulp-protractor").protractor;

gulp.src(["./src/tests/*.js"])
	.pipe(protractor({
		configFile: "test/protractor.config.js",
		args: ['--baseUrl', 'http://127.0.0.1:8000']
	}))
	.on('error', function(e) { throw e })

Protractor Webdriver

You have to update and start a standalone selenium server. Please read the offical instructions.

You can also ensure that the driver is installed by using the webdriver_update task. Have a look at the example folder.

You have 2 options to start the selenium server.

The first one is to let Protractor handle it automatically, including stopping it once your tests are done.
To do that, simply point to the selenium jar in the protractor config file (you will need to update the version number accordingly) instead of the address:

  // The file path to the selenium server jar ()
  seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
  // seleniumAddress: 'http://localhost:4444/wd/hub',

The second option is to let the gulp task handle it with the built-in webdriver snippet.
If you decide to start it that way, the task will keep running indefinitely.

var webdriver_standalone = require("gulp-protractor").webdriver_standalone;
gulp.task('webdriver_standalone', webdriver_standalone);

API

protractor(options)

options.configFile

Type: String
Default: null

The path to your protractor config

options.args

Type: Array
Default: []

Arguments get passed directly to the protractor call Read the docs for more information

options.debug

Type: Boolean Default: false

Enables Protractor's debug mode, which can be used to pause tests during execution and to view stack traces.

Running Protractor without a plugin

If you want to avoid using a plugin at all, here are gulp tasks which install the webdriver and start protractor:

First install the protractor package: npm install --save-dev protractor

Then add these tasks to your gulpfile.js:

var gulp = require('gulp');
var path = require('path');
var child_process = require('child_process');

function getProtractorBinary(binaryName){
	var winExt = /^win/.test(process.platform)? '.cmd' : '';
	var pkgPath = require.resolve('protractor');
	var protractorDir = path.resolve(path.join(path.dirname(pkgPath), '..', 'bin'));
	return path.join(protractorDir, '/'+binaryName+winExt);
}

gulp.task('protractor-install', function(done){
	child_process.spawn(getProtractorBinary('webdriver-manager'), ['update'], {
		stdio: 'inherit'
	}).once('close', done);
});

gulp.task('protractor-run', function (done) {
	var argv = process.argv.slice(3); // forward args to protractor
	child_process.spawn(getProtractorBinary('protractor'), argv, {
		stdio: 'inherit'
	}).once('close', done);
});

You can add command line arguments for protractor behind the gulp task:

gulp protractor-run --specs=runOnlyThisFile.js

License

MIT License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.