Socket
Socket
Sign inDemoInstall

protractor

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protractor - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

plugins/accessibility/index.js

4

config.json
{
"webdriverVersions": {
"selenium": "2.44.0",
"selenium": "2.45.0",
"chromedriver": "2.14",
"iedriver": "2.44.0"
"iedriver": "2.45.0"
}
}

@@ -16,4 +16,4 @@ Browser Support

|ios-Driver |No | |
|Appium - iOS/Safari |Yes* | drag and drop not supported (session/:sessionid/buttondown unimplemented) |
|Appium - Android/Chrome |Yes* | |
|Appium - iOS/Safari |Yes* |[Link](https://github.com/angular/protractor/labels/browser%3A%20iOS%20safari) |
|Appium - Android/Chrome |Yes* |[Link](https://github.com/angular/protractor/labels/browser%3A%20android%20chrome) |
|Selendroid |Yes* | |

@@ -20,0 +20,0 @@ |PhantomJS / GhostDriver |** |[Link](https://github.com/angular/protractor/labels/browser%3A%20phantomjs) |

@@ -46,3 +46,3 @@ var path = require('path'),

configDir: './',
plugins: {}
plugins: []
};

@@ -49,0 +49,0 @@ };

@@ -28,3 +28,3 @@ var repl = require('repl');

type: 'scriptRegExp',
target: 'selenium-webdriver/executors.js',
target: '.*executors\.js', //jshint ignore:line
line: 37

@@ -31,0 +31,0 @@ }, function() {});

@@ -36,3 +36,3 @@ var repl = require('repl');

type: 'scriptRegExp',
target: 'selenium-webdriver/executors.js',
target: '.*executors\.js', //jshint ignore:line
line: 37

@@ -39,0 +39,0 @@ }, function() {

@@ -465,5 +465,7 @@ var util = require('util');

* @example
* element.all(by.css('.items li')).each(function(element) {
* // Will print First, Second, Third.
* element.getText().then(console.log);
* element.all(by.css('.items li')).each(function(element, index) {
* // Will print 0 First, 1 Second, 2 Third.
* element.getText().then(function (text) {
* console.log(index, text);
* });
* });

@@ -470,0 +472,0 @@ *

var q = require('q'),
helper = require('./util'),
ConfigParser = require('./configParser');
ConfigParser = require('./configParser'),
log = require('./logger');

@@ -14,12 +15,9 @@ var logPrefix = '[plugins]';

var args = [logPrefix].concat([].slice.call(arguments));
console.log.apply(console, args);
log.puts.apply(log, args);
};
/**
* The plugin API for Protractor. Note that this API is extremely unstable
* and current consists of only two functions:
* <plugin>.setup - called before tests
* <plugin>.teardown - called after tests
* <plugin>.postResults - called after test results have been processed
* More information on plugins coming in the future
* The plugin API for Protractor. Note that this API is unstable. See
* plugins/README.md for more information.
*
* @constructor

@@ -29,6 +27,7 @@ * @param {Object} config parsed from the config file

var Plugins = function(config) {
this.pluginConfs = config.plugins;
this.pluginObjs = {};
for (var name in this.pluginConfs) {
var pluginConf = this.pluginConfs[name];
var self = this;
this.pluginConfs = config.plugins || [];
this.pluginObjs = [];
this.pluginConfs.forEach(function(pluginConf) {
var path;

@@ -39,14 +38,43 @@ if (pluginConf.path) {

} else {
path = pluginConf.package || name;
path = pluginConf.package;
}
this.pluginObjs[name] = require(path);
}
if (!path) {
throw new Error('Plugin configuration did not contain a valid path.');
}
pluginConf.name = path;
self.pluginObjs.push(require(path));
});
};
var green = '\x1b[32m';
var red = '\x1b[31m';
var normalColor = '\x1b[39m';
var noop = function() {};
Plugins.printPluginResults = function(specResults) {
var green = '\x1b[32m';
var red = '\x1b[31m';
var normalColor = '\x1b[39m';
var printResult = function(message, pass) {
log.puts(pass ? green : red,
'\t', pass ? 'Pass: ' : 'Fail: ', message, normalColor);
};
for (var j = 0; j < specResults.length; j++) {
var specResult = specResults[j];
var passed = specResult.assertions.map(function(x) {
return x.passed;
}).reduce(function(x, y) {
return x && y;
}, true);
printResult(specResult.description, passed);
if (!passed) {
for (var k = 0; k < specResult.assertions.length; k++) {
if (!specResult.assertions[k].passed) {
log.puts('\t\t' + specResult.assertions[k].errorMsg);
}
}
}
}
};
function pluginFunFactory(funName) {

@@ -56,8 +84,12 @@ return function() {

var promises = [];
for (var name in this.pluginConfs) {
var pluginConf = this.pluginConfs[name];
var pluginObj = this.pluginObjs[name];
names.push(name);
promises.push((pluginObj[funName] || noop)(pluginConf));
for (var i = 0; i < this.pluginConfs.length; ++i) {
var pluginConf = this.pluginConfs[i];
var pluginObj = this.pluginObjs[i];
names.push(pluginObj.name || pluginConf.name);
promises.push(
(pluginObj[funName] || noop).apply(
pluginObj[funName],
[pluginConf].concat([].slice.call(arguments))));
}
return q.all(promises).then(function(results) {

@@ -77,22 +109,4 @@ // Join the results into a single object and output any test results

if (pluginResult.specResults) {
console.log('Plugin: ' + names[i] + ' (' + funName + ')');
for (var j = 0; j < pluginResult.specResults.length; j++) {
var specResult = pluginResult.specResults[j];
var passed = specResult.assertions.map(function(x) {
return x.passed;
}).reduce(function(x, y) {
return x && y;
}, true);
console.log(passed ? green : red, '\t' + specResult.description,
normalColor);
if (!passed) {
for (var k = 0; k < specResult.assertions.length; k++) {
if (!specResult.assertions[k].passed) {
console.log(red, '\t\t' +
specResult.assertions[k].errorMsg, normalColor);
}
}
}
}
log.puts('Plugin: ' + names[i] + ' (' + funName + ')');
Plugins.printPluginResults(pluginResult.specResults);
}

@@ -135,2 +149,10 @@

/**
* Called after each test block completes.
*
* @return {q.Promise} A promise which resolves when the plugins have all been
* torn down.
*/
Plugins.prototype.postTest = pluginFunFactory('postTest');
module.exports = Plugins;

@@ -314,5 +314,23 @@ var protractor = require('./protractor'),

// We need to save these promises to make sure they're run, but we don't
// want to delay starting the next test (because we can't, it's just
// an event emitter).
var pluginPostTestPromises = [];
self.on('testPass', function() {
pluginPostTestPromises.push(plugins.postTest(true));
});
self.on('testFail', function() {
pluginPostTestPromises.push(plugins.postTest(false));
});
return require(frameworkPath).run(self, self.config_.specs).
then(function(testResults) {
return helper.joinTestLogs(pluginSetupResults, testResults);
return q.all(pluginPostTestPromises).then(function(postTestResultList) {
var results = helper.joinTestLogs(pluginSetupResults, testResults);
postTestResultList.forEach(function(postTestResult) {
results = helper.joinTestLogs(results, postTestResult);
});
return results;
});
});

@@ -319,0 +337,0 @@ // 5) Teardown plugins

@@ -27,3 +27,5 @@ {

"lodash": "~2.4.1",
"source-map-support": "~0.2.6"
"source-map-support": "~0.2.6",
"html-entities": "~1.1.1",
"accessibility-developer-tools": "~2.6.0"
},

@@ -57,3 +59,3 @@ "devDependencies": {

"license": "MIT",
"version": "1.7.0"
"version": "1.8.0"
}

@@ -23,3 +23,3 @@ Protractor Plugins

plugins[{
plugins: [{
// The only required field for each plugin is the path to that

@@ -29,3 +29,3 @@ // plugin's entry script.

// Plugins may use additional options specified here. See the
// Plugins may use additional options specified here. See the
// individual plugin docs for more information.

@@ -38,5 +38,28 @@ option1: 'foo',

Protractor contains built in plugins in the 'plugins' folder. An example of
using the 'ngHint' plugin is shown below.
```javascript
plugins: [{
path: 'node_modules/protractor/plugins/ngHint',
}]
```
Finally, if your plugin is a node module, you may use it with the `package`
option. For example, if you did `npm install example-protractor-plugin` your
config would look like:
```javascript
plugins: [{
package: 'example-protractor-plugin',
}]
```
Writing Plugins
---------------
Plugins are designed to work with any test framework (Jasmine, Mocha, etc),
so they use generic hooks which Protractor provides. Plugins may change
the output of Protractor by returning a results object.
Plugins are node modules which export an object with the following API:

@@ -78,2 +101,20 @@

exports.postResults = function(config) {};
/**
* Called after each test block (in Jasmine, this means an `it` block)
* completes.
*
* @param {Object} config The plugin configuration object.
* @param {boolean} passed True if the test passed.
*
* @return Object If an object is returned, it is merged with the Protractor
* result object. May return a promise.
*/
exports.postTest = function(config, passed) {};
/**
* Used when reporting results.
* @type {string}
*/
exports.name = '';
```

@@ -80,0 +121,0 @@

@@ -19,3 +19,3 @@ Protractor [![Build Status](https://travis-ci.org/angular/protractor.png?branch=master)](https://travis-ci.org/angular/protractor)

To better understand how Protractor works with the Selenium WebDriver and Selenium Sever see the reference materials.
To better understand how Protractor works with the Selenium WebDriver and Selenium Server see the reference materials.

@@ -22,0 +22,0 @@

@@ -38,3 +38,4 @@ #!/usr/bin/env node

'node lib/cli.js plugins/timeline/spec/conf.js',
'node lib/cli.js plugins/ngHint/spec/successConfig.js');
'node lib/cli.js plugins/ngHint/spec/successConfig.js',
'node lib/cli.js plugins/accessibility/spec/successConfig.js');

@@ -101,2 +102,12 @@ var executor = new Executor();

executor.addCommandlineTest('node lib/cli.js spec/errorTest/pluginsFailingConf.js')
.expectExitCode(1)
.expectErrors([
{message: 'Expected true to be false'},
{message: 'from setup'},
{message: 'from postTest passing'},
{message: 'from postTest failing'},
{message: 'from teardown'}
]);
// Check ngHint plugin

@@ -117,2 +128,14 @@

// Check accessibility plugin
executor.addCommandlineTest(
'node lib/cli.js plugins/accessibility/spec/failureConfig.js')
.expectExitCode(1)
.expectErrors([{
message: '3 elements failed:'
},
{
message: '1 element failed:'
}]);
executor.execute();

@@ -16,3 +16,3 @@ #!/usr/bin/env node

describe('ngversion', 'version of AngularJS to use').
default('ngversion', '1.3.0-rc0').
default('ngversion', '1.3.13').
argv;

@@ -19,0 +19,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc