function test (file) { file = join('fixtures', 'broken-pipe', file) t.test(file, { parallel: true }, async ({ is }) => { const child = fork(join(__dirname, file), { silent: true }) child.stdout.destroy() child.stderr.pipe(process.stdout) const res = await once(child, 'close') is(res, 0) // process exits successfully }) }
t.test('let error pass through', ({ is, plan }) => { plan(3) const stream = pino.destination() // side effect of the pino constructor is that it will set an // event handler for error pino(stream) process.nextTick(() => stream.emit('error', new Error('kaboom'))) process.nextTick(() => stream.emit('error', new Error('kaboom'))) stream.on('error', (err) => { is(err.message, 'kaboom') }) })
tap.throws(function () { throw new Error('bang!') })
tap.doesNotThrow(function () {})
tap.test('log method hook', t => { t.test('gets invoked', async t => { t.plan(6)
tap.throws(function () {})
tap.doesNotThrow(function () { throw new Error('bang!') })
tap.tearDown(function() { setTimeout(function() { server.close(); }, 1000); });
tap.test('Appmetrics should be a global singleton', function(t) { var appmetrics = require('../'); // Delete cached module delete require.cache[require.resolve('../')]; var appmetrics2 = require('../'); t.equals(appmetrics, appmetrics2); t.end(); });
monitor.on('request', function(data) { if (completedTests < 4) { tap.test('HTTP Request Event', function(t) { checkHttpRequestData(data.request.context, t); t.end(); completedTests++; }); } });
monitor.once('initialized', function() { tap.test('Environment Data', function(t) { var nodeEnv = monitor.getEnvironment(); console.log('Got initialized event!'); console.dir(nodeEnv); runNodeEnvTests(nodeEnv, t); runCommonEnvTests(nodeEnv, t); t.end(); }); });
tap.test('start returns this', function(t) { t.equal(appmetrics, app.appmetrics); t.equal(appmetrics, require('../')); t.end(); });
monitor.on('http-outbound', function(data) { tap.test('HTTP Outbound Event', function(t) { checkHttpOutboundData(data, t); t.end(); }); });
monitor.on('http', function(data) { if (completedTests < 2) { tap.test('HTTP Event', function(t) { checkHttpData(data, t); t.end(); completedTests++; }); } });
monitor.on('request', function(data) { tap.test('HTTPS Request Event', function(t) { checkHttpsRequestData(data.request.context, t); t.end(); }); });