How to use the tape.createHarness function in tape

To help you get started, we’ve selected a few tape examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antonycourtney / tad / test / runAllTests.js View on Github external
* into tap-spec via node pipes rather than stdin / stdout.
 *
 * I found large auxiliary output (like console.log'ing a large table)
 * would encounter buffering issues when using stdin / stdout.
 *
 * Never isolated exact cause, but creating and managing stream in
 * Node explicitly seems to work.
 *
 * Unfortunately that tickles another issue: in-process streams
 * wouldn't print summary information:
 * See: https://github.com/scottcorgan/tap-spec/issues/37
 * and https://github.com/scottcorgan/tap-spec/issues/37#issuecomment-268949364
 * for my workaround.
 */

let htest = test.createHarness()

htest.createStream()
  .pipe(formatter)
  .pipe(process.stdout)

/*
htest.createStream()
  .pipe(tapSpec())
  .pipe(process.stdout)
*/

// A fetch polyfill using ReadFile that assumes url is relative:
function readFileAsync (file, options) {
  return new Promise(function (resolve, reject) {
    fs.readFile(file, options, function (err, data) {
      if (err) {
github krakenjs / shortstop-handlers / test / index.js View on Github external
handler = commons.exec(__dirname);
        t.equal(typeof handler, 'function');
        t.equal(handler.length, 1);

        // Method
        expected = 'myFunction';
        actual = handler('./fixtures#myFunction');
        t.equal(actual, expected);

        // Module
        expected = 'myModule';
        actual = handler('./fixtures');
        t.equal(actual, expected);

        // NPM
        expected = require('tape').createHarness();
        actual = handler('tape#createHarness');
        t.equal(typeof actual, typeof expected);
        t.deepEqual(Object.keys(actual), Object.keys(expected));


        // Missing function
        t.throws(function () {
            handler('./fixtures#notFound');
        });

        // Non-existent module
        t.throws(function () {
            handler('./tape');
        });

        // Non-function module
github Stremio / stremio-addons / test / addon-protocol.js View on Github external
async.eachSeries(addons, function(url, ready) {
	var test = tape.createHarness();

	/* Send errors to Slack webhook
	 */
	var errors = 0, output = [];
	// WARNING: we can't do createStream more than once, because it bugs the first test
	test.createStream({ /* objectMode: true */ }).on("data", function(x) {
		if (x.match("^not ok")) { errors++; hasErr = true }
		output.push(x);
		process.stdout.write(x);
	}).on("end", function() {
		if (errors < 2) return ready();
		if (!slackPush) return ready();
				
		var body = require("querystring").stringify({ payload: JSON.stringify({ 
			channel: slackChannel || "#mon-stremio", username: "webhookbot",
			text: "*WARNING: "+url+" failing "+(slackMessage || "")+" with "+errors+" errors *\n",
github hoodiehq / hoodie / tests / unit / index.js View on Github external
var http = require('http')
var url = require('url')

localStorage.clear()

var test = require('tape').createHarness()

require('./api.js')(test)
require('./hoodie.js')(test)
require('./plugins.js')(test)
require('./walkthrough.js')(test)

var reqOptions = url.parse(process.env.TEST_RESULT_SERVER)
reqOptions.method = 'POST'
test.createStream()

.on('data', console.log.bind(console))
.pipe(http.request(reqOptions, function () {
  console.log('results uploaded')
}))
github substance / substance / tests / harness.js View on Github external
'use strict';

var tape = require('tape');
var inBrowser = require('../util/inBrowser');
var platform = require('../util/platform');
var DefaultDOMElement = require('../ui/DefaultDOMElement');

var nextTick = process.nextTick;
var harness = tape.createHarness();
var results = harness._results;

harness.runAllTests = function() {
  var i = 0;
  function next() {
    while (i < results.tests.length) {
      var t = results.tests[i++];
      t.once('end', function(){ nextTick(next); });
      t.run();
    }
  }
  nextTick(next);
};

harness.getTests = function() {
  return results.tests || [];
github workshopper / browserify-adventure / lib / verify.js View on Github external
return function (args, cb) {
        var test = tape.createHarness();
        test(function (t) { fn(args, t) });
        var stream = test.createStream();
        stream.pipe(parser(function (results) { cb(results.ok) }));
        return stream.pipe(faucet());
    };
};
github hayes / unpm / scripts / coverage.js View on Github external
var cov = require('mocha-lcov-reporter')
  , blanket = require('blanket')
  , glob = require('glob')
  , path = require('path')
  , tape = require('tape')
  , test

blanket = blanket({pattern: path.resolve(__dirname, '../lib/')})
blanket.setupCoverage()
test = tape.createHarness()
cov(test.createStream())

var cache = require.cache[
  path.resolve(__dirname, '../node_modules/tape/index.js')
]

cache.exports = test

require('../index')
require('../test')