karma-sharding
Advanced tools
Comparing version 4.2.2 to 4.3.0
@@ -9,6 +9,12 @@ { | ||
}, | ||
"extends": "eslint:recommended", | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:security/recommended" | ||
], | ||
"globals": { | ||
"FakeNews": true | ||
}, | ||
"plugins": [ | ||
"security" | ||
], | ||
"rules": { | ||
@@ -30,4 +36,5 @@ "indent": [ | ||
"always" | ||
] | ||
], | ||
"security/detect-object-injection": 0 | ||
} | ||
} |
@@ -28,2 +28,3 @@ const _ = require('lodash'); | ||
// modified from example at: | ||
// https://stackoverflow.com/questions/8188548/splitting-a-js-array-into-n-arrays | ||
@@ -33,12 +34,19 @@ function splitArray(flatArray, numCols){ | ||
const nestedArray = _.chunk(flatArray, maxColLength); | ||
let newArray = []; | ||
for (var i = 0; i < numCols; i++) { | ||
newArray[i] = nestedArray[i] || []; | ||
for (var i = nestedArray.length; i < numCols; i++) { | ||
nestedArray.push([]); | ||
} | ||
return newArray; | ||
return nestedArray; | ||
} | ||
function isSpecFile(url, matcher) { | ||
return ( | ||
url.indexOf('/bower_components/') === -1 && | ||
url.indexOf('/node_modules/') === -1 && | ||
matcher.test(url) | ||
); | ||
} | ||
function setupSets(config, basePath, files) { | ||
var specs = files.served.map(f => config.base + f.path.replace(basePath, '')) | ||
.filter(p => config.specMatcher.test(p)); | ||
.filter(p => isSpecFile(p, config.specMatcher)); | ||
config.sets = splitArray(specs, config.browserCount); | ||
@@ -45,0 +53,0 @@ var lastSet = config.sets && config.sets.length && config.sets[config.sets.length - 1]; |
@@ -38,2 +38,10 @@ const idParamExtractor = /\/\?id=(\d+)/; | ||
function isSpecFile(url, matcher) { | ||
return ( | ||
url.indexOf('/bower_components/') === -1 && | ||
url.indexOf('/node_modules/') === -1 && | ||
matcher.test(url) | ||
); | ||
} | ||
module.exports = function(/* config */fullConfig, /* config.sharding */config, logger) { | ||
@@ -45,3 +53,3 @@ | ||
setBrowserIdCookie(request, response); | ||
if (config.performSharding && config.specMatcher.test(request.url)) { | ||
if (config.performSharding && isSpecFile(request.url, config.specMatcher)) { | ||
if (notInSet(config, log, request, response) === 1) { | ||
@@ -48,0 +56,0 @@ return; |
{ | ||
"name": "karma-sharding", | ||
"version": "4.2.2", | ||
"version": "4.3.0", | ||
"description": "Karma plugin to allow tests to be distributed across multiple browsers", | ||
@@ -59,2 +59,3 @@ "engines": { | ||
"eslint": "^4.9.0", | ||
"eslint-plugin-security": "^1.4.0", | ||
"jasmine-core": "^2.8.0", | ||
@@ -61,0 +62,0 @@ "karma": "^1.7.1", |
35790
685
6