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

karma-tap

Package Overview
Dependencies
Maintainers
30
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-tap - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

lib/parser.js

6

index.js

@@ -0,1 +1,3 @@

var path = require('path');
var createPattern = function(path) {

@@ -6,4 +8,4 @@ return {pattern: path, included: true, served: true, watched: false};

var initTAP = function(files, tapConfig) {
files.unshift(createPattern(__dirname + '/src/adapter.js'));
files.unshift(createPattern(__dirname + '/src/tap-parser.js'));
files.unshift(createPattern(__dirname + '/src/adapter.js'));
files.unshift(createPattern(__dirname + '/lib/parser.js'));
};

@@ -10,0 +12,0 @@

{
"name": "karma-tap",
"version": "1.0.4",
"version": "2.0.0",
"description": "adapter from karma to the tape testing framework",
"main": "index.js",
"scripts": {
"clean": "rimraf lib",
"build:parser": "browserify src/parser.js --s tapParser -o lib/parser.js",
"build-npm": "npm run clean && mkdirp lib && npm run build:parser",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -21,9 +24,16 @@ },

"author": "Tom MacWright",
"contributors": [
"bySabi Files <> (https://github.com/bySabi)"
],
"license": "ISC",
"peerDependencies": {
"karma": "1.x.x"
},
"devDependencies": {
"karma": "^0.12.28"
},
"dependencies": {
"tap-parser": "^1.2.2"
"browserify": "13.x.x",
"tap-parser": "1.x.x",
"tap-finished": "0.0.1",
"mkdirp": "*",
"rimraf": "*"
}
}
# Karma TAP adapter
This adapter reads [TAP](http://testanything.org/) output from runners like
[tape](https://github.com/substack/tape) into [Karma](http://karma-runner.github.io/0.12/index.html).
[tape](https://github.com/substack/tape) into [Karma](http://karma-runner.github.io/1.0/index.html)

@@ -25,1 +25,4 @@ ## Installation

```
## TAP Protocol
Support TAP Protocol version `13`

@@ -1,59 +0,77 @@

var createStartFn = function(tc, env) {
var numResults = 0;
var res = [];
var startTime = new Date().getTime();
var parse_stream = tapParser(function(results) {
tc.info({ total: numResults });
for (var i = 0, len = res.length; i < len; i++) {
tc.result(res[i]);
}
tc.complete({
coverage: window.__coverage__
// global object tapParser from 'parser.js'
var finished = tapParser.finished;
var parser = tapParser.parser;
function createStartFn(tc) {
return function(config) {
var numResults = 0;
var done = false;
var res = [];
var suite = '';
var startTime = new Date().getTime();
var parse_stream = parser();
var skip = /^# SKIP\s/;
parse_stream.on('comment', function(comment) {
// handle skipped test
if (skip.test(comment)) {
res.push({
description: comment.replace(skip, ''),
skipped: true
});
return;
}
// TODO: validate if comment is a test 'name'
suite = comment;
});
}).on('assert', function(assertion) {
numResults++;
res.push({
description: assertion.name,
success: assertion.ok,
log: [JSON.stringify(assertion.diag || assertion, null, 2)],
suite: [],
time: new Date().getTime() - startTime
parse_stream.on('assert', function(assertion) {
numResults++;
res.push({
description: assertion.name,
success: assertion.ok,
log: [JSON.stringify(assertion.diag || assertion, null, 2)],
suite: [suite],
time: new Date().getTime() - startTime
});
});
});
// this part lifted from zuul
// https://github.com/defunctzombie/zuul/blob/master/frameworks/tape/client.js
var originalLog = console.log;
console.log = function (msg) {
if (!parse_stream.writable) return;
var index = 1;
var args = arguments;
if (typeof msg === 'string') {
msg = msg.replace(/(^|[^%])%[sd]/g, function (_, s) {
return s + args[index++];
parse_stream.on('complete', function(results) {
tc.info({ total: numResults });
for (var i = 0, len = res.length; i < len; i++) {
tc.result(res[i]);
}
tc.complete({
coverage: window.__coverage__
});
}
});
for (var i = index; i < args.length; i++) {
msg += ' ' + args[i];
}
parse_stream.write(msg + '\n');
if (/^# fail\s*\d+$/.test(msg) || /^# ok/.test(msg)) {
// reset console.log to make sure this stream doesn't get a write error.
console.log = originalLog;
// this part lifted from zuul
// https://github.com/defunctzombie/zuul/blob/master/frameworks/tape/client.js
var finished_stream = finished(function() {
done = true;
parse_stream.end();
}
});
if (typeof originalLog === 'function') {
return originalLog.apply(this, arguments);
var originalLog = console.log;
console.log = function () {
var msg = arguments[0];
// do not write in a closed WriteStream
if (!done) {
parse_stream.write(msg + '\n');
finished_stream.write(msg + '\n');
}
// transfer log to original console,
// this shows the tap output in console
// and also let the user add console logs
if (typeof originalLog === 'function') {
return originalLog.apply(this, arguments);
}
}
else if (originalLog) return originalLog(arguments[0]);
};
return function(config) {
};
}
};
window.__karma__.start = createStartFn(window.__karma__);
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