karma-parallel
Advanced tools
Comparing version 0.2.9 to 0.3.0
@@ -5,8 +5,14 @@ 'use strict'; | ||
function initKarmaParallelizer(root, karma, shardIndexInfo) { | ||
if (!shardIndexInfo || !shardIndexInfo.shouldShard) { | ||
// console.log('Skipping sharding. Could not find index and count values'); | ||
function initKarmaParallelizer(root, karma, shardIndexInfoMap) { | ||
var idParamExtractor = /(\?|&)id=(\d+)(&|$)/; | ||
var matches = idParamExtractor.exec(parent.location.search); | ||
var id = matches && matches[2] || null; | ||
if (!id || !shardIndexInfoMap.hasOwnProperty(id) || !shardIndexInfoMap[id].shouldShard) { | ||
/* eslint-disable-next-line no-console */ | ||
console.warn('Skipping sharding. Could not find karma-parallel initialization data.'); | ||
return; | ||
} | ||
var shardIndexInfo = shardIndexInfoMap[id]; | ||
var strategy = overrideSuiteStategy(getSpecSuiteStrategy(shardIndexInfo)); | ||
@@ -13,0 +19,0 @@ var fakeContextStatus = createFakeTestContext(root, strategy); |
@@ -12,30 +12,23 @@ 'use strict'; | ||
const idParamExtractor = /\/\?id=(\d+)/; | ||
const idCookieExtractor = /karmaParallelBrowser.id=(\d+)/; | ||
function createKarmaSharderInfoMap(config) { | ||
return JSON.stringify(Object | ||
.keys(config.shardIndexMap) | ||
.map((id) => [ id, { | ||
shouldShard: !!id && config.shardIndexMap.hasOwnProperty(id), | ||
shardIndex: config.shardIndexMap[id], | ||
executors: config.executors, | ||
shardStrategy: config.shardStrategy | ||
} ]) | ||
.reduce((payloadMap, [ id, payload ]) => { | ||
payloadMap[id.toString()] = payload; | ||
function setBrowserIdCookie(log, request, response) { | ||
if (request.url.indexOf('/?id=') === 0) { | ||
const id = idParamExtractor.exec(request.url)[1]; | ||
const cookie = `karmaParallelBrowser.id=${id};`; | ||
log.debug(`setting cookie "${cookie}"`); | ||
response.setHeader('Set-Cookie', cookie); | ||
} | ||
return payloadMap; | ||
}, { })); | ||
} | ||
function getBrowserIdCookie(request) { | ||
const match = idCookieExtractor.exec(request.headers.cookie); | ||
return match && match.length && match[1]; | ||
} | ||
function writeKarmaSharderInfo(log, config, request, response) { | ||
const id = getBrowserIdCookie(request); | ||
const payload = JSON.stringify({ | ||
shouldShard: !!id && config.shardIndexMap.hasOwnProperty(id), | ||
shardIndex: config.shardIndexMap[id], | ||
executors: config.executors, | ||
shardStrategy: config.shardStrategy | ||
}); | ||
log.debug(`interpolating parallel shard data in script. Browser: ${id}. Data: ${payload}`); | ||
function writeKarmaSharderInfoMap(log, config, response) { | ||
const karmaSharderInfoMap = createKarmaSharderInfoMap(config); | ||
log.debug(`interpolating parallel shard data map in script. Data: ${karmaSharderInfoMap}`); | ||
response.writeHead(200, {'Content-Type': 'application/javascript'}); | ||
response.end(karmaParallelScript.replace('%KARMA_SHARD_INFO%', payload)); | ||
response.end(karmaParallelScript.replace('%KARMA_SHARD_INFO%', karmaSharderInfoMap)); | ||
} | ||
@@ -73,8 +66,5 @@ | ||
return function (request, response, next) { | ||
// Responsible for finding the id of the browser and saving it as a cookie so all future requests can access it | ||
setBrowserIdCookie(log, request, response); | ||
// Intercept the request for the actual sharding script so we can interpolate the browser-specific shard data in it | ||
// Intercept the request for the actual sharding script so we can interpolate the shard data in it | ||
if (request.url.indexOf(karmaParallelScriptName) !== -1) { | ||
return writeKarmaSharderInfo(log, config, request, response); | ||
return writeKarmaSharderInfoMap(log, config, response); | ||
} | ||
@@ -81,0 +71,0 @@ |
@@ -11,5 +11,8 @@ { | ||
], | ||
"peerDependencies": { | ||
"karma": ">= 1.0.0" | ||
}, | ||
"dependencies": { | ||
"istanbul": "^0.4.5", | ||
"lodash": "^4.17.5" | ||
"lodash": "^4.17.11" | ||
}, | ||
@@ -19,16 +22,16 @@ "description": "A Karma JS Framework to support sharding tests to run in parallel across multiple browsers", | ||
"chai": "^4.1.2", | ||
"eslint": "^4.9.0", | ||
"eslint": "^5.6.0", | ||
"eslint-plugin-security": "^1.4.0", | ||
"jasmine": "^3.0.0", | ||
"jasmine-core": "^2.8.0", | ||
"karma": "^1.7.1", | ||
"jasmine": "^3.2.0", | ||
"jasmine-core": "^2.99.1", | ||
"karma": "^3.0.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-coverage-istanbul-reporter": "^1.4.1", | ||
"karma-jasmine": "^1.1.1", | ||
"karma-coverage": "^1.1.2", | ||
"karma-coverage-istanbul-reporter": "^1.4.3", | ||
"karma-jasmine": "^1.1.2", | ||
"karma-junit-reporter": "^1.2.0", | ||
"karma-mocha": "^1.3.0", | ||
"mocha": "^5.0.1", | ||
"npm-run-all": "^4.1.2" | ||
"mocha": "^5.2.0", | ||
"npm-run-all": "^4.1.3" | ||
}, | ||
@@ -79,5 +82,5 @@ "directories": { | ||
"lint": "eslint --fix --config .eslintrc.json lib/\\*.js test/\\*.js index.js", | ||
"test": "npm run lint && npm run karma" | ||
"test": "run-p --aggregate-output lint karma" | ||
}, | ||
"version": "0.2.9" | ||
"version": "0.3.0" | ||
} |
@@ -39,3 +39,3 @@ # karma-parallel | ||
### Basic | ||
### Basic Installation | ||
@@ -48,2 +48,14 @@ ```javascript | ||
frameworks: ['parallel', 'mocha' /* or 'jasmine' */], | ||
}); | ||
}; | ||
``` | ||
### Additional Configuration | ||
```javascript | ||
// karma.conf.js | ||
module.exports = function(config) { | ||
config.set({ | ||
// NOTE: 'parallel' must be the first framework in the list | ||
frameworks: ['parallel', 'mocha' /* or 'jasmine' */], | ||
plugins: [ | ||
@@ -120,3 +132,3 @@ // add karma-parallel to the plugins if you encounter something like "karma parallel No provider for framework:parallel" | ||
* Requires the spec files to reside in separate files, meaning it is not compatible with bundlers such | ||
as [`karma-webpack`](https://github.com/webpack-contrib/karma-webpack) or [`karma-browserify`](https://github.com/nikku/karma-browserify) | ||
as [`karma-webpack`](https://github.com/webpack-contrib/karma-webpack) or [`karma-browserify`](https://github.com/nikku/karma-browserify) as used with most front end cli projects (e.g. @angular/cli) | ||
@@ -123,0 +135,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40550
136
3
753
+ Added@colors/colors@1.5.0(transitive)
+ Added@socket.io/component-emitter@3.1.2(transitive)
+ Added@types/cookie@0.4.1(transitive)
+ Added@types/cors@2.8.17(transitive)
+ Added@types/node@22.9.1(transitive)
+ Addedaccepts@1.3.8(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedbase64id@2.0.0(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedcliui@7.0.4(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedconnect@3.7.0(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookie@0.7.2(transitive)
+ Addedcors@2.8.5(transitive)
+ Addedcustom-event@1.0.1(transitive)
+ Addeddate-format@4.0.14(transitive)
+ Addeddebug@2.6.94.3.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddi@0.0.1(transitive)
+ Addeddom-serialize@2.2.1(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedencodeurl@1.0.2(transitive)
+ Addedengine.io@6.6.2(transitive)
+ Addedengine.io-parser@5.2.3(transitive)
+ Addedent@2.2.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedeventemitter3@4.0.7(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfinalhandler@1.1.2(transitive)
+ Addedflatted@3.3.2(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedfs-extra@8.1.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addedhttp-proxy@1.18.1(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedisbinaryfile@4.0.10(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedkarma@6.4.4(transitive)
+ Addedlog4js@6.9.1(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.3.02.4.1(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqjobs@1.2.0(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedrfdc@1.4.1(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedsocket.io@4.8.1(transitive)
+ Addedsocket.io-adapter@2.5.5(transitive)
+ Addedsocket.io-parser@4.2.4(transitive)
+ Addedstatuses@1.5.02.0.1(transitive)
+ Addedstreamroller@3.1.5(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedtmp@0.2.3(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addedvary@1.1.2(transitive)
+ Addedvoid-elements@2.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedws@8.17.1(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@16.2.0(transitive)
+ Addedyargs-parser@20.2.9(transitive)
Updatedlodash@^4.17.11