How to use the tap.fail function in tap

To help you get started, we’ve selected a few tap 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 metarhia / jstp / test / node / default-reconnector-backoff.js View on Github external
server.on('message', ([type, port]) => {
  test.plan(EXPECTED_ATTEMPTS_TO_RECONNECT);

  if (type !== 'listening') {
    test.fail('must not receive unknown messages');
  }

  jstp.net.connect(
    APP_NAME,
    null,
    port,
    'localhost',
    (error, connection) => {
      test.assertNot(error, 'must connect to server and perform handshake');

      connection.on('error', () => {
        // dismiss
      });

      server.kill('SIGTERM');
github tapjs / t-up / tup.js View on Github external
child.on('exit', function (exitCode, signal) {
    // almost certainly won't get an 'exit' event if we've already
    // unrefed the child, but avoid a false failure anyway.
    /* istanbul ignore else */
    if (!unrefed) {
      t.fail('child process exited early', {
        exitCode: exitCode,
        signal: signal
      })
    }
  })
}
github metarhia / jstp / test / node / session-resend-event-on-connection-drop.js View on Github external
client.on('message', ([message, ...args]) => {
  switch (message) {
    case 'error':
      console.error(args[0].message);
      test.fail('must not encounter an error');
      break;
    case 'session':
      session(...args);
      break;
  }
});
github fastify / fastify / test / http2 / plain.js View on Github external
'use strict'

const t = require('tap')
const test = t.test
const Fastify = require('../..')
const h2url = require('h2url')
const msg = { hello: 'world' }

var fastify
try {
  fastify = Fastify({
    http2: true
  })
  t.pass('http2 successfully loaded')
} catch (e) {
  t.fail('http2 loading failed', e)
}

fastify.get('/', function (req, reply) {
  reply.code(200).send(msg)
})

fastify.listen(0, err => {
  t.error(err)
  fastify.server.unref()

  test('http get request', async (t) => {
    t.plan(3)

    const url = `http://localhost:${fastify.server.address().port}`
    const res = await h2url.concat({ url })
github tapjs / tap-parser / test / omit-version.js View on Github external
p.on('version', function (v) {
  t.fail('should not see version event')
})
var lines = []
github metarhia / jstp / test / node / resendable-call-from-server.js View on Github external
method: (connection, callback) => {
      callsReceivedByClient++;
      if (callsReceivedByClient === 1) {
        test.pass('Client must receive first call message');
        reconnect();
      } else if (callsReceivedByClient === 2) {
        test.pass('Client must receive second call message');
        callback(null);
      } else {
        test.fail('Client must not receive more than two call messages');
      }
    },
  },
github metarhia / jstp / test / node / resendable-call-from-client.js View on Github external
method: (connection, callback) => {
      callsReceivedByServer++;
      if (callsReceivedByServer === 1) {
        test.pass('Server must receive first call message');
        reconnect();
      } else if (callsReceivedByServer === 2) {
        test.pass('Server must receive second call message');
        callback(null);
      } else {
        test.fail('Server must not receive more than two call messages');
      }
    },
  },
github LLK / scratch-www / test / localization-legacy / check_valid_json.js View on Github external
const checkJson = (data, name) => {
    try {
        JSON.parse(data);
    } catch (e) {
        tap.fail(name + ' has invalid Json.\n');
    }
};
github ibmruntimes / yieldable-json / test / test-stringify-intensity.js View on Github external
yj.stringifyAsync(obj, 0, 2, (err, str) => {
  if (!err) {
    tap.ok(flag >= 1, 'Async function was expected to yield at least' +
           ` once, but got ${flag}!`);
  } else
    tap.fail(err);
});
github LLK / scratch-www / test / localization-legacy / check_string_ids.js View on Github external
const noMissingStrings = (fileName, missingMessageId, pagesMissingIds) => {
    if (Object.keys(missingMessageId).length === 0) {
        tap.pass();
    } else {
        tap.fail(fileName + ' is missing string IDs');
        pagesMissingIds[fileName] = [];
        pagesMissingIds[fileName].push(missingMessageId);
    }
};