Socket
Socket
Sign inDemoInstall

grunt-saucelabs

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-saucelabs - npm Package Compare versions

Comparing version 6.0.0 to 7.0.0

tasks/promise-scheduler.js

1

Gruntfile.js

@@ -111,2 +111,3 @@ module.exports = function(grunt) {

testname: "jasmine tests",
throttled: 3,
sauceConfig: {

@@ -113,0 +114,0 @@ 'video-upload-on-pass': false

2

package.json
{
"name": "grunt-saucelabs",
"description": "Grunt task running tests using Sauce Labs. Supports QUnit, Jasmine, Mocha and YUI tests",
"version": "6.0.0",
"version": "7.0.0",
"homepage": "https://github.com/axemclion/grunt-saucelabs",

@@ -6,0 +6,0 @@ "author": {

@@ -214,2 +214,5 @@ grunt-saucelabs

---------
####7.0.0####
* `throttled` parameter now represents the max number of jobs sent concurrently. Previously was `throttled * browsers.length`
####6.0.0####

@@ -216,0 +219,0 @@ * default `testInterval` changed to 2000ms

@@ -5,3 +5,4 @@ module.exports = function(grunt) {

SauceTunnel = require('sauce-tunnel'),
Q = require('q');
Q = require('q'),
scheduler = require('./promise-scheduler');

@@ -94,3 +95,2 @@ //these result parsers return true if the tests all passed

this.testInterval = testInterval;
this.results = [];
};

@@ -102,38 +102,13 @@

var numberOfJobs = browsers.length * urls.length;
var addResultPromise = function(promise){
me.results.push(promise);
grunt.log.writeln(me.results.length, "/", numberOfJobs, 'tests started');
if (me.results.length == numberOfJobs){
var startedJobs = 0;
Q.all(me.results).then(function(results){
results = results.map(function(result){
return result.valueOf().passed;
});
function take(url, browser) {
return me.runTest(browser, url, framework, tunnelIdentifier, testname, tags, build)
.then(function (taskId) {
callback(results);
});
}
};
startedJobs += 1;
grunt.log.writeln("\n",startedJobs, "/", numberOfJobs, 'tests started');
var outstandingTests = 0;
function take() {
var url = urls.shift();
if (url) {
outstandingTests++;
me.runTest(browsers, url, framework, tunnelIdentifier, testname, tags, build, function (taskIds) {
var outstandingTasks = taskIds.length;
function taskComplete() {
outstandingTasks--;
if (outstandingTasks === 0) {
outstandingTests--;
takeMany();
}
}
taskIds.forEach(function (taskId) {
var resultPromise = new TestResult(taskId, me.user, me.key, framework, me.testInterval);
addResultPromise(resultPromise);
resultPromise.then(function (result) {
return TestResult(taskId, me.user, me.key, framework, me.testInterval)
.then(function (result) {
var alteredResult = onTestComplete(result);

@@ -157,31 +132,34 @@ if (alteredResult !== undefined) {

grunt.log.writeln("Url %s", result.url);
taskComplete();
return result;
}, function (e) {
grunt.log.error('some error? %s', e);
taskComplete();
});
});
});
}
}
throttled = throttled || Number.MAX_VALUE;
var throttledTake = scheduler.limitConcurrency(take, throttled || Number.MAX_VALUE);
var promises = urls
.map(function (url) {
return browsers.map(function (browser) {
return throttledTake(url, browser);
});
})
.reduce(function (acc, promisesForUrl) {
return acc.concat(promisesForUrl);
}, []);
function takeMany() {
while (urls.length && outstandingTests < throttled) {
take();
}
}
Q.all(promises)
.then(function (results) {
results = results.map(function (result) {
return result.passed;
});
takeMany();
callback(results);
})
.done();
};
TestRunner.prototype.runTest = function(browsers, url, framework, tunnelIdentifier, build, testname, sauceConfig, callback){
TestRunner.prototype.runTest = function(browser, url, framework, tunnelIdentifier, build, testname, sauceConfig){
var parsePlatforms = function(browsers){
return browsers.map(function(browser){
return [browser.platform || "", browser.browserName || "", browser.version || ""];
});
};
var requestParams = {

@@ -196,7 +174,7 @@ method: 'post',

body: {
platforms: parsePlatforms(browsers),
platforms: [[browser.platform || "", browser.browserName || "", browser.version || ""]],
url: url,
framework: framework,
build: build,
name: testname,
name: testname
}

@@ -210,17 +188,20 @@ };

rqst(requestParams, function(error, response, body){
return Q.nfcall(rqst, requestParams)
.then(
function (result) {
var body = result[1],
taskIds = body['js tests'];
if (error){
grunt.log.error("Could not connect to Sauce Labs api: %s", error);
throw error;
}
if (!taskIds || !taskIds.length){
grunt.log.error('Error starting tests through Sauce API: %s', JSON.stringify(body));
throw new Error('Could not start tests through Sauce API');
}
if (!body['js tests'] || !body['js tests'].length){
grunt.log.error('Error starting tests through Sauce API: %s', JSON.stringify(body));
throw new Error('Could not start tests through Sauce API');
}
callback(body['js tests']);
});
return taskIds[0];
},
function (error) {
grunt.log.error("Could not connect to Sauce Labs api: %s", error);
throw error;
}
);
};

@@ -227,0 +208,0 @@

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