Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karma-parallel

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-parallel - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

56

lib/karma-parallelizer.js

@@ -11,6 +11,17 @@ 'use strict';

const overrideSpecSuite = getSpecSuiteOverrider(shardIndexInfo);
['describe', 'ddescribe', 'fdescribe'].forEach(function(methodName) {
replaceMethod(root, methodName, overrideSpecSuite);
const strategy = getSpecSuiteStrategy(shardIndexInfo);
const overrideSpecSuite = createSpecSuiteOverrider(strategy);
// Mocha uses describe.only|skip
// Jasmine uses fdescribe|ddescribe|xdescribe
replaceMethod(root, 'describe', function(method) {
const overriden = overrideSpecSuite(method);
replaceMethod(overriden, 'only', overrideSpecSuite);
replaceMethod(overriden, 'skip', overrideSpecSuite);
return overriden;
});
replaceMethod(root, 'xdescribe', overrideSpecSuite);
replaceMethod(root, 'fdescribe', overrideSpecSuite);
replaceMethod(root, 'ddescribe', overrideSpecSuite);
}

@@ -39,19 +50,19 @@

function getSpecSuiteOverrider(shardIndexInfo) {
function getSpecSuiteStrategy(shardIndexInfo) {
switch (shardIndexInfo.shardStrategy) {
case 'description-length':
return createDescriptionLengthSpecSuiteOverrider(shardIndexInfo);
return createDescriptionLengthStragegy(shardIndexInfo);
case 'round-robin':
/* falls through */
default:
return createRoundRobinBasedSpecSuiteOverrider(shardIndexInfo);
return createRoundRobinStrategy(shardIndexInfo);
}
}
function createDescriptionLengthSpecSuiteOverrider({shardIndex, executors}) {
function createSpecSuiteOverrider(strategy) {
let depth = 0;
return function overrideSpecSuite(origDescribe) {
return function(description, specDefinitions) {
// If we are a top-level describe but our description doesn't match our responsibility, skip it
if (depth === 0 && description.length % executors !== shardIndex) {
// If we are a top-level, ask our strategy if we should be interested in this suite
if (depth === 0 && !strategy(description, specDefinitions)) {
// console.log('[skipping]', description);

@@ -69,19 +80,14 @@ } else {

function createRoundRobinBasedSpecSuiteOverrider({shardIndex, executors}) {
let depth = 0;
function createDescriptionLengthStragegy({shardIndex, executors}) {
return function overrideSpecSuite(description/*, specDefinitions*/) {
return description.length % executors === shardIndex;
};
}
function createRoundRobinStrategy({shardIndex, executors}) {
// Increment the count on each top level describe to determine
// round-robin responsibility
let count = 0;
return function overrideSpecSuite(origDescribe) {
return function(description, specDefinitions) {
// If we are a top-level describe but our description doesn't match our responsibility, skip it
if (depth === 0 && count++ % executors !== shardIndex) {
// console.log('[skipping]', description);
} else {
origDescribe(description, function() {
depth++;
specDefinitions();
depth--;
});
}
};
return function(/*description, specDefinitions*/) {
return count++ % executors === shardIndex;
};

@@ -88,0 +94,0 @@ }

@@ -57,3 +57,3 @@ {

},
"version": "0.1.0"
"version": "0.1.1"
}
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