karma-jasmine
Advanced tools
Comparing version 0.3.7 to 0.3.8
(function(window) { | ||
/* jshint globalstrict: true */ | ||
'use strict'; | ||
'use strict' | ||
@@ -11,8 +11,8 @@ /** | ||
*/ | ||
function isExternalStackEntry(entry) { | ||
return (entry ? true : false) && | ||
// entries related to jasmine and karma-jasmine: | ||
!/\/(jasmine-core|karma-jasmine)\//.test(entry) && | ||
// karma specifics, e.g. "at http://localhost:7018/karma.js:185" | ||
!/\/(karma.js|context.html):/.test(entry); | ||
function isExternalStackEntry (entry) { | ||
return (entry ? true : false) && | ||
// entries related to jasmine and karma-jasmine: | ||
!/\/(jasmine-core|karma-jasmine)\//.test(entry) && | ||
// karma specifics, e.g. "at http://localhost:7018/karma.js:185" | ||
!/\/(karma.js|context.html):/.test(entry) | ||
} | ||
@@ -25,11 +25,11 @@ | ||
*/ | ||
function getRelevantStackFrom(stack) { | ||
function getRelevantStackFrom (stack) { | ||
var filteredStack = [], | ||
relevantStack = []; | ||
relevantStack = [] | ||
stack = stack.split('\n'); | ||
stack = stack.split('\n') | ||
for (var i = 0; i < stack.length; i += 1) { | ||
if (isExternalStackEntry(stack[i])) { | ||
filteredStack.push(stack[i]); | ||
filteredStack.push(stack[i]) | ||
} | ||
@@ -41,3 +41,3 @@ } | ||
if (filteredStack.length === 0) { | ||
filteredStack = stack; | ||
filteredStack = stack | ||
} | ||
@@ -47,7 +47,7 @@ | ||
if (filteredStack[i]) { | ||
relevantStack.push(filteredStack[i]); | ||
relevantStack.push(filteredStack[i]) | ||
} | ||
} | ||
return relevantStack; | ||
return relevantStack | ||
} | ||
@@ -67,3 +67,3 @@ | ||
*/ | ||
function formatFailedStep(step) { | ||
function formatFailedStep (step) { | ||
// Safari seems to have no stack trace, | ||
@@ -73,10 +73,10 @@ // so we just return the error message: | ||
var relevantMessage = []; | ||
var relevantStack = []; | ||
var relevantMessage = [] | ||
var relevantStack = [] | ||
// Remove the message prior to processing the stack to prevent issues like | ||
// https://github.com/karma-runner/karma-jasmine/issues/79 | ||
var stack = step.stack.replace('Error: ' + step.message, ''); | ||
var stack = step.stack.replace('Error: ' + step.message, '') | ||
var dirtyRelevantStack = getRelevantStackFrom(stack); | ||
var dirtyRelevantStack = getRelevantStackFrom(stack) | ||
@@ -91,7 +91,7 @@ // PhantomJS returns multiline error message for errors coming from specs | ||
// we consider it to be a relevant stack: | ||
relevantStack.push(dirtyRelevantStack[i]); | ||
relevantStack.push(dirtyRelevantStack[i]) | ||
} else { | ||
// Stack entry is already in the message, | ||
// we consider it to be a suitable message alternative: | ||
relevantMessage.push(dirtyRelevantStack[i]); | ||
relevantMessage.push(dirtyRelevantStack[i]) | ||
} | ||
@@ -103,3 +103,3 @@ } | ||
// Let's reuse the original message: | ||
relevantMessage.push(step.message); | ||
relevantMessage.push(step.message) | ||
@@ -112,3 +112,3 @@ // Now we probably have a repetition case where: | ||
// the stack to get rid of repetition : | ||
relevantStack.shift(); | ||
relevantStack.shift() | ||
} | ||
@@ -123,34 +123,32 @@ } | ||
// at /foo/bar/baz.js:18:29 | ||
return relevantMessage.concat(relevantStack).join('\n'); | ||
return relevantMessage.concat(relevantStack).join('\n') | ||
} | ||
function SuiteNode (name, parent) { | ||
this.name = name | ||
this.parent = parent | ||
this.children = [] | ||
function SuiteNode(name, parent) { | ||
this.name = name; | ||
this.parent = parent; | ||
this.children = []; | ||
this.addChild = function (name) { | ||
var suite = new SuiteNode(name, this); | ||
this.children.push(suite); | ||
return suite; | ||
}; | ||
var suite = new SuiteNode(name, this) | ||
this.children.push(suite) | ||
return suite | ||
} | ||
} | ||
function processSuite (suite, pointer) { | ||
var child | ||
var childPointer | ||
function processSuite(suite, pointer) { | ||
var child; | ||
var childPointer; | ||
for (var i = 0; i < suite.children.length; i++) { | ||
child = suite.children[i]; | ||
child = suite.children[i] | ||
if (child.children) { | ||
childPointer = pointer[child.description] = {_: []}; | ||
processSuite(child, childPointer); | ||
childPointer = pointer[child.description] = {_: []} | ||
processSuite(child, childPointer) | ||
} else { | ||
if (!pointer._) { | ||
pointer._ = []; | ||
pointer._ = [] | ||
} | ||
pointer._.push(child.description); | ||
pointer._.push(child.description) | ||
} | ||
@@ -160,19 +158,16 @@ } | ||
function getAllSpecNames (topSuite) { | ||
var specNames = {} | ||
function getAllSpecNames(topSuite) { | ||
var specNames = {}; | ||
processSuite(topSuite, specNames) | ||
processSuite(topSuite, specNames); | ||
return specNames; | ||
return specNames | ||
} | ||
/** | ||
* Very simple reporter for Jasmine. | ||
*/ | ||
function KarmaReporter(tc, jasmineEnv) { | ||
function KarmaReporter (tc, jasmineEnv) { | ||
var currentSuite = new SuiteNode() | ||
var currentSuite = new SuiteNode(); | ||
/** | ||
@@ -182,4 +177,4 @@ * @param suite | ||
*/ | ||
function isTopLevelSuite(suite) { | ||
return suite.description === 'Jasmine_TopLevel_Suite'; | ||
function isTopLevelSuite (suite) { | ||
return suite.description === 'Jasmine_TopLevel_Suite' | ||
} | ||
@@ -203,20 +198,17 @@ | ||
specs: getAllSpecNames(jasmineEnv.topSuite()) | ||
}); | ||
}; | ||
}) | ||
} | ||
this.jasmineDone = function () { | ||
tc.complete({ | ||
coverage: window.__coverage__ | ||
}); | ||
}; | ||
}) | ||
} | ||
this.suiteStarted = function (result) { | ||
if (!isTopLevelSuite(result)) { | ||
currentSuite = currentSuite.addChild(result.description); | ||
currentSuite = currentSuite.addChild(result.description) | ||
} | ||
}; | ||
} | ||
this.suiteDone = function (result) { | ||
@@ -226,44 +218,43 @@ // In the case of xdescribe, only "suiteDone" is fired. | ||
if (result.description !== currentSuite.name) { | ||
return; | ||
return | ||
} | ||
currentSuite = currentSuite.parent; | ||
}; | ||
currentSuite = currentSuite.parent | ||
} | ||
this.specStarted = function (specResult) { | ||
specResult.startTime = new Date().getTime(); | ||
}; | ||
specResult.startTime = new Date().getTime() | ||
} | ||
this.specDone = function (specResult) { | ||
var skipped = specResult.status === 'disabled' || specResult.status === 'pending'; | ||
var skipped = specResult.status === 'disabled' || specResult.status === 'pending' | ||
var result = { | ||
description : specResult.description, | ||
id : specResult.id, | ||
log : [], | ||
skipped : skipped, | ||
success : specResult.failedExpectations.length === 0, | ||
suite : [], | ||
time : skipped ? 0 : new Date().getTime() - specResult.startTime | ||
}; | ||
description: specResult.description, | ||
id: specResult.id, | ||
log: [], | ||
skipped: skipped, | ||
success: specResult.failedExpectations.length === 0, | ||
suite: [], | ||
time: skipped ? 0 : new Date().getTime() - specResult.startTime, | ||
executedExpectationsCount: specResult.failedExpectations.length + specResult.passedExpectations.length | ||
} | ||
// generate ordered list of (nested) suite names | ||
var suitePointer = currentSuite; | ||
var suitePointer = currentSuite | ||
while (suitePointer.parent) { | ||
result.suite.unshift(suitePointer.name); | ||
suitePointer = suitePointer.parent; | ||
result.suite.unshift(suitePointer.name) | ||
suitePointer = suitePointer.parent | ||
} | ||
if (!result.success) { | ||
var steps = specResult.failedExpectations; | ||
var steps = specResult.failedExpectations | ||
for (var i = 0, l = steps.length; i < l; i++) { | ||
result.log.push(formatFailedStep(steps[i])); | ||
result.log.push(formatFailedStep(steps[i])) | ||
} | ||
} | ||
tc.result(result); | ||
delete specResult.startTime; | ||
}; | ||
tc.result(result) | ||
delete specResult.startTime | ||
} | ||
} | ||
@@ -276,25 +267,25 @@ | ||
*/ | ||
var getGrepOption = function(clientArguments) { | ||
var grepRegex = /^--grep=(.*)$/; | ||
var getGrepOption = function (clientArguments) { | ||
var grepRegex = /^--grep=(.*)$/ | ||
if (Object.prototype.toString.call(clientArguments) === '[object Array]') { | ||
var indexOfGrep = clientArguments.indexOf('--grep'); | ||
var indexOfGrep = clientArguments.indexOf('--grep') | ||
if(indexOfGrep !== -1) { | ||
return clientArguments[indexOfGrep + 1]; | ||
if (indexOfGrep !== -1) { | ||
return clientArguments[indexOfGrep + 1] | ||
} | ||
return clientArguments | ||
.filter(function(arg) { | ||
return grepRegex.test(arg); | ||
}) | ||
.map(function(arg) { | ||
return arg.replace(grepRegex, '$1'); | ||
})[0] || ''; | ||
.filter(function (arg) { | ||
return grepRegex.test(arg) | ||
}) | ||
.map(function (arg) { | ||
return arg.replace(grepRegex, '$1') | ||
})[0] || '' | ||
} else if (typeof clientArguments === 'string') { | ||
var match = /--grep=([^=]+)/.exec(clientArguments); | ||
var match = /--grep=([^=]+)/.exec(clientArguments) | ||
return match ? match[1] : ''; | ||
return match ? match[1] : '' | ||
} | ||
}; | ||
} | ||
@@ -305,10 +296,10 @@ /** | ||
*/ | ||
var KarmaSpecFilter = function(options) { | ||
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | ||
var filterPattern = new RegExp(filterString); | ||
var KarmaSpecFilter = function (options) { | ||
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') | ||
var filterPattern = new RegExp(filterString) | ||
this.matches = function(specName) { | ||
return filterPattern.test(specName); | ||
}; | ||
}; | ||
this.matches = function (specName) { | ||
return filterPattern.test(specName) | ||
} | ||
} | ||
@@ -319,13 +310,13 @@ /** | ||
*/ | ||
var createSpecFilter = function(config, jasmineEnv) { | ||
var createSpecFilter = function (config, jasmineEnv) { | ||
var specFilter = new KarmaSpecFilter({ | ||
filterString: function() { | ||
return getGrepOption(config.args); | ||
filterString: function () { | ||
return getGrepOption(config.args) | ||
} | ||
}); | ||
}) | ||
jasmineEnv.specFilter = function(spec) { | ||
return specFilter.matches(spec.getFullName()); | ||
}; | ||
}; | ||
jasmineEnv.specFilter = function (spec) { | ||
return specFilter.matches(spec.getFullName()) | ||
} | ||
} | ||
@@ -342,16 +333,49 @@ /** | ||
*/ | ||
function createStartFn(karma, jasmineEnv) { | ||
function createStartFn (karma, jasmineEnv) { | ||
// This function will be assigned to `window.__karma__.start`: | ||
return function () { | ||
jasmineEnv = jasmineEnv || window.jasmine.getEnv(); | ||
jasmineEnv = jasmineEnv || window.jasmine.getEnv() | ||
jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv)); | ||
jasmineEnv.execute(); | ||
}; | ||
jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv)) | ||
jasmineEnv.execute() | ||
} | ||
} | ||
// Polyfills for correct work adapter in IE8 | ||
if (!('indexOf' in Array.prototype)) { | ||
Array.prototype.indexOf = function (find, i /*opt*/) { | ||
if (i === undefined) {i = 0;} | ||
if (i < 0) {i += this.length;} | ||
if (i < 0) {i = 0;} | ||
for (var n = this.length; i < n; i++) { | ||
if (i in this && this[i] === find) { | ||
return i;}} | ||
return -1 | ||
} | ||
} | ||
createSpecFilter(window.__karma__.config, jasmine.getEnv()); | ||
window.__karma__.start = createStartFn(window.__karma__); | ||
if (!('map' in Array.prototype)) { | ||
Array.prototype.map = function (mapper, that /*opt*/) { | ||
var other = new Array(this.length) | ||
for (var i = 0, n = this.length; i < n; i++) { | ||
if (i in this) { | ||
other[i] = mapper.call(that, this[i], i, this);}} | ||
return other | ||
} | ||
} | ||
if (!('filter' in Array.prototype)) { | ||
Array.prototype.filter = function (filter, that /*opt*/) { | ||
var other = [], v | ||
for (var i = 0, n = this.length; i < n; i++) { | ||
if (i in this && filter.call(that, v = this[i], i, this)) { | ||
other.push(v);}} | ||
return other | ||
} | ||
} | ||
createSpecFilter(window.__karma__.config, jasmine.getEnv()) | ||
window.__karma__.start = createStartFn(window.__karma__) | ||
})(typeof window !== 'undefined' ? window : global); |
@@ -6,6 +6,5 @@ /** | ||
*/ | ||
(function (global) { | ||
;(function (global) { | ||
/*global jasmineRequire */ | ||
'use strict'; | ||
'use strict' | ||
@@ -16,3 +15,3 @@ /** | ||
*/ | ||
var jasmine = jasmineRequire.core(jasmineRequire); | ||
var jasmine = jasmineRequire.core(jasmineRequire) | ||
@@ -22,3 +21,3 @@ /** | ||
*/ | ||
var jasmineInterface = jasmineRequire.interface(jasmine, jasmine.getEnv()); | ||
var jasmineInterface = jasmineRequire.interface(jasmine, jasmine.getEnv()) | ||
@@ -29,6 +28,6 @@ /** | ||
*/ | ||
global.setTimeout = global.setTimeout; | ||
global.setInterval = global.setInterval; | ||
global.clearTimeout = global.clearTimeout; | ||
global.clearInterval = global.clearInterval; | ||
global.setTimeout = global.setTimeout | ||
global.setInterval = global.setInterval | ||
global.clearTimeout = global.clearTimeout | ||
global.clearInterval = global.clearInterval | ||
@@ -43,6 +42,5 @@ /** | ||
if (jasmineInterface.hasOwnProperty(property)) { | ||
global[property] = jasmineInterface[property]; | ||
global[property] = jasmineInterface[property] | ||
} | ||
} | ||
}(typeof window !== 'undefined' ? window : global)); | ||
}(typeof window !== 'undefined' ? window : global)) |
@@ -1,18 +0,18 @@ | ||
var path = require('path'); | ||
var path = require('path') | ||
var createPattern = function(path) { | ||
return {pattern: path, included: true, served: true, watched: false}; | ||
}; | ||
var createPattern = function (pattern) { | ||
return {pattern: pattern, included: true, served: true, watched: false} | ||
} | ||
var initJasmine = function(files) { | ||
var jasminePath = path.dirname(require.resolve('jasmine-core')); | ||
files.unshift(createPattern(__dirname + '/adapter.js')); | ||
files.unshift(createPattern(__dirname + '/boot.js')); | ||
files.unshift(createPattern(jasminePath + '/jasmine-core/jasmine.js')); | ||
}; | ||
var initJasmine = function (files) { | ||
var jasminePath = path.dirname(require.resolve('jasmine-core')) | ||
files.unshift(createPattern(path.join(__dirname, '/adapter.js'))) | ||
files.unshift(createPattern(path.join(__dirname, '/boot.js'))) | ||
files.unshift(createPattern(jasminePath + '/jasmine-core/jasmine.js')) | ||
} | ||
initJasmine.$inject = ['config.files']; | ||
initJasmine.$inject = ['config.files'] | ||
module.exports = { | ||
'framework:jasmine': ['factory', initJasmine] | ||
}; | ||
} |
{ | ||
"name": "karma-jasmine", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"description": "A Karma plugin - adapter for Jasmine testing framework.", | ||
@@ -21,13 +21,18 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-jshint": "~0.6", | ||
"eslint-config-standard": "^5.1.0", | ||
"eslint-plugin-promise": "^1.1.0", | ||
"eslint-plugin-standard": "^1.3.2", | ||
"grunt": "~0.4.5", | ||
"grunt-bump": "^0.7.0", | ||
"grunt-conventional-changelog": "^6.1.0", | ||
"grunt-conventional-github-releaser": "^1.0.0", | ||
"grunt-eslint": "^18.0.0", | ||
"grunt-karma": "~0.12.1", | ||
"grunt-npm": "0.0.2", | ||
"jasmine-core": "~2.4.1", | ||
"karma": "", | ||
"karma-jasmine": "~0.3.0", | ||
"karma-chrome-launcher": "~0.2.0", | ||
"karma-firefox-launcher": "~0.1.0", | ||
"grunt-karma": "~0.12.0", | ||
"grunt-auto-release": "~0.0.2", | ||
"grunt-npm": "~0.0.2", | ||
"grunt-bump": "~0.0.7", | ||
"jasmine-core": "~2.3.4" | ||
"karma-chrome-launcher": "~0.2.2", | ||
"karma-firefox-launcher": "~0.1.7", | ||
"karma-jasmine": "~0.3.7", | ||
"load-grunt-tasks": "^3.4.1" | ||
}, | ||
@@ -41,9 +46,10 @@ "peerDependencies": { | ||
"olegskl <sklyanchuk@gmail.com>", | ||
"dignifiedquire <dignifiedquire@gmail.com>", | ||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>", | ||
"Cornelius Schmale <github@cschmale.de>", | ||
"Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>", | ||
"Arthur Thornton <arthur@thestorefront.com>", | ||
"Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>", | ||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>", | ||
"Mark Ethan Trostler <mark@zzo.com>", | ||
"Richard Park <objectiv@gmail.com>", | ||
"dignifiedquire <dignifiedquire@gmail.com>", | ||
"Stefan Dragnev <dragnev@telerik.com>", | ||
"jiverson <jiverson222@gmail.com>", | ||
@@ -56,8 +62,8 @@ "Aaron Hartwig <aaron.hartwig@whyhigh.com>", | ||
"Matthew Hill <Matthew.Hill4@bskyb.com>", | ||
"Milan Lempera <milanlempera@gmail.com>", | ||
"Niels Dequeker <niels.dequeker@gmail.com>", | ||
"Robin Gloster <robin@loc-com.de>", | ||
"Sahat Yalkabov <sakhat@gmail.com>", | ||
"Sergey Tatarintsev <sevinf@yandex-team.ru>", | ||
"Stefan Dragnev <dragnev@telerik.com>" | ||
"Sergey Tatarintsev <sevinf@yandex-team.ru>" | ||
] | ||
} |
@@ -1,3 +0,8 @@ | ||
# karma-jasmine [![Build Status](https://travis-ci.org/karma-runner/karma-jasmine.svg?branch=master)](https://travis-ci.org/karma-runner/karma-jasmine) | ||
# karma-jasmine | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-jasmine) | ||
[![npm version](https://img.shields.io/npm/v/karma-jasmine.svg?style=flat-square)](https://www.npmjs.com/package/karma-jasmine) [![npm downloads](https://img.shields.io/npm/dm/karma-jasmine.svg?style=flat-square)](https://www.npmjs.com/package/karma-jasmine) | ||
[![Build Status](https://img.shields.io/travis/karma-runner/karma-jasmine/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-jasmine) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-jasmine.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-jasmine) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-jasmine.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-jasmine#info=devDependencies) | ||
> Adapter for the [Jasmine](http://jasmine.github.io/) testing framework. | ||
@@ -10,16 +15,6 @@ | ||
The easiest way is to keep `karma-jasmine` as a devDependency in your `package.json`. | ||
The easiest way is to run | ||
```json | ||
{ | ||
"devDependencies": { | ||
"karma": "~0.12.0", | ||
"karma-jasmine": "~0.1.0" | ||
} | ||
} | ||
``` | ||
You can simply do it by: | ||
```bash | ||
npm install karma-jasmine --save-dev | ||
$ npm install karma-jasmine@0.1.0 --save-dev | ||
``` | ||
@@ -30,15 +25,6 @@ | ||
The easiest way is to keep `karma-jasmine` as a devDependency in your `package.json`. | ||
```json | ||
{ | ||
"devDependencies": { | ||
"karma": "~0.12.0", | ||
"karma-jasmine": "~0.2.0" | ||
} | ||
} | ||
``` | ||
The easiest way is run | ||
You can simply do it by: | ||
```bash | ||
npm install karma-jasmine@2_0 --save-dev | ||
$ npm install karma-jasmine --save-dev | ||
``` | ||
@@ -48,6 +34,9 @@ | ||
Since `karma-jasmine 0.3.0` the jasmine library is no longer bundled with `karma-jasmine` and you have to install it on your own. You can simply do it by: | ||
```bash | ||
npm install jasmine-core --save-dev | ||
$ npm install jasmine-core --save-dev | ||
``` | ||
## Configuration | ||
```js | ||
@@ -62,4 +51,4 @@ // karma.conf.js | ||
] | ||
}); | ||
}; | ||
}) | ||
} | ||
``` | ||
@@ -70,4 +59,4 @@ | ||
```bash | ||
karma start & | ||
karma run -- --grep=<pattern> | ||
$ karma start & | ||
$ karma run -- --grep=<pattern> | ||
``` | ||
@@ -85,4 +74,4 @@ | ||
} | ||
}); | ||
}; | ||
}) | ||
} | ||
``` | ||
@@ -89,0 +78,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
19838
9
436
16
79
1
1