test('authenticate does not try to open browser in SSH session', async function (t) { const openStub = url => t.fail('should not try to open browser') const origEnv = process.env process.env = { ...origEnv, SSH_CLIENT: '127.0.0.1 1234 22' } // IP PID port t.on('end', () => { process.env = origEnv }) const authenticate = proxyquire('../lib/authenticate', { open: openStub }) const jwtToken = await authenticate(`http://127.0.0.1:${server.address().port}`, { ask: true }) t.ok(jwtToken) })
test('authenticate failure', async function (t) { const openStub = url => openSuccess() const authenticate = proxyquire( '../lib/authenticate', { open: openStub, split2: () => ({ on: () => [] }) }) try { await authenticate(`http://127.0.0.1:${server.address().port}`) t.fail('it should reject') } catch (err) { t.plan(1) t.ok(err) } })
test('authenticate timeout', async function (t) { const openStub = url => openSuccess() const authenticate = proxyquire('../lib/authenticate', { open: openStub }) // mocking the browser opening simulateTimeout = true t.on('end', () => { simulateTimeout = false }) try { await authenticate(`http://127.0.0.1:${server.address().port}`) t.fail('it should reject') } catch (err) { t.plan(2) t.ok(err) t.ok(err.message.includes('Authentication timed out')) } })
t.fail('should not request the server') res.end() })
t.fail('should not request the server') res.end() })
tap.test('Setting Watchdog threshold to high value, no profiling data expected', function(t) { app.appmetrics.disable('profiling'); delay(100); app.appmetrics.setConfig('advancedProfiling', { threshold: 1000 }); app.appmetrics.enable('profiling'); monitor.on('profiling', function(data) { t.fail('Profiling data was produced in error'); }); delay(200); delay(200); delay(200); delay(200); delay(200); setTimeout(function() { t.end(); }, 5000); });
// NOTE: This needs to be updated when tests are added/removed tap.test('Headless mode should produce a .hcd file', function(t) { setTimeout(function() { fs.readdir(outputDir, function(error, files) { if (error) { t.fail('An error occurred: ' + error); t.end(); cleanUp(); return; } for (var i = 0, len = files.length; i < len; i++) { if (/(\w+)\.hcd/.test(files[i].toString())) { t.pass(files[i] + ' HCD file found'); t.end(); cleanUp(); return; } } t.fail('No .hcd file found'); t.end(); cleanUp(); }); }, 70000); });
"lru-cache-fs": class { constructor({ cwd }) { t.fail("should not acess cache");
test("build a list of items that gets all items filtered out as prefixed scripts", t => { t.plan(1); const ntl = requireInject("../../cli", { "read-pkg": { sync: () => ({ scripts: { prebuild: 'echo "prebuild"', pretest: 'echo "pretest"' } }) }, ipt: expected => { t.fail("should not build interactive interface"); return Promise.resolve([]); }, "simple-output": { error: msg => { t.equal( msg, "No tasks remained, maybe try less options?", "should show error message suggesting less options" ); } } }); });
t.fail("should not build interactive interface"); return Promise.resolve([]); },
test("build a list of items that gets all items filtered out from --exclude option", t => { t.plan(1); const ntl = requireInject("../../cli", { "read-pkg": { sync: () => ({ scripts: { build: 'echo "build"', test: 'echo "test"' } }) }, ipt: expected => { t.fail("should not build interactive interface"); return Promise.resolve([]); }, "simple-output": { error: msg => { t.equal( msg, "No tasks remained, maybe try less options?", "should show error message suggesting less options" ); } }, "yargs/yargs": mockYargs({ _: [], exclude: ["build", "test"] }) }); });
test('authenticate no auth token', async function (t) { const openStub = url => openSuccess() const authenticate = proxyquire('../lib/authenticate', { open: openStub }) // mocking the browser opening simulateNoToken = true t.on('end', () => { simulateNoToken = false }) try { await authenticate(`http://127.0.0.1:${server.address().port}`) t.fail('it should reject') } catch (err) { t.plan(2) t.ok(err) t.ok(err.message.includes('Authentication failed. No token obtained')) } })
}, ipt: expected => { t.fail("should not build interactive interface"); return Promise.resolve([]); },
"lru-cache-fs": class { constructor({ cwd }) { t.fail("should not acess cache");
}, ipt: expected => { t.fail("should not build interactive interface"); return Promise.resolve([]); },