test('stack is omitted if it is not set on err', t => { t.plan(2) var err = new Error('myerror') delete err.stack var instance = pino(sink(function (chunk, enc, cb) { t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') delete chunk.time t.equal(chunk.hasOwnProperty('stack'), false) cb() })) instance.level = name instance[name](err) })
test('stack is rendered as any other property if it\'s not a string', t => { t.plan(3) var err = new Error('myerror') err.stack = null var instance = pino(sink(function (chunk, enc, cb) { t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') delete chunk.time t.equal(chunk.hasOwnProperty('stack'), true) t.equal(chunk.stack, null) cb() })) instance.level = name instance[name](err) })
test("ntl forward trailing options", t => { const cwd = t.testdir({ "package.json": JSON.stringify({ scripts: { test: "node test.js" } }), "test.js": "console.log(process.argv.slice(2).join(''))" }); const cp = run({ cwd }, ["--all", "--", "--one-more-thing"]); cp.assertNotStderrData(t); cp.getStdoutResult().then(res => { t.equal( readLastLine(res), "--one-more-thing", "should forward trailing options" ); t.end(); }); cp.stdin.write("\n"); cp.stdin.end(); });
test("error while use --debug option", t => { const _exit = process.exit; process.exit = code => { t.equal(code, 1, "should exit with error signal"); }; t.teardown(() => { process.exit = _exit; }); t.plan(2); const ntl = requireInject("../../cli", { ipt: () => Promise.reject(new Error("ERR")), "simple-output": { node: () => null, success: () => null, error: msg => { t.equal( msg, "Error building interactive interface", "should forward original error message" ); }, info: () => null } }); });
"lru-cache-fs": class { constructor({ max }) { t.equal(max, 3, "should use properly cast cache max value");
child_process: { execSync: cmd => { t.equal( cmd, "npm run build -- --one-more-thing",
test("press esc key", t => { const _exit = process.exit; const _stdin = process.stdin; process.exit = code => { t.equal(code, 0, "should exit with error signal"); t.end(); }; t.teardown(() => { process.exit = _exit; }); const ntl = requireInject("../../cli", { ipt: () => Promise.resolve([]), "simple-output": { node: () => null, success: () => null, error: msg => { t.equal( msg, "Error building interactive interface", "should forward original error message" ); }, info: () => null } }); // simulate esc key process.stdin.emit("keypress", "", { name: "escape" }); });
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" ); } } }); });
test("select one item from the list", t => { const ntl = requireInject("../../cli", { "read-pkg": { sync: () => ({ scripts: { test: "make test", build: "make build" } }) }, ipt: expected => { return Promise.resolve(["build"]); }, child_process: { execSync: cmd => { t.equal(cmd, "npm run build", "should run the selected task"); t.end(); } }, "simple-output": { node: () => null, success: () => null } }); });
test("error while use --debug option", t => { const _exit = process.exit; process.exit = code => { t.equal(code, 1, "should exit with error signal"); }; t.teardown(() => {
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("ntl run and select first item", t => { const cwd = t.testdir({ "package.json": JSON.stringify({ scripts: { build: 'echo "build"' }, ntl: { runner: "echo" } }) }); const cp = run({ cwd }); cp.assertNotStderrData(t); cp.getStdoutResult().then(res => { t.equal( readLastLine(res), "run build", "should config-defined custom runner" ); t.end(); }); cp.stdin.write("\n"); cp.stdin.end(); });
test("ntl run and select first item", t => { const cwd = t.testdir({ "package.json": JSON.stringify({ scripts: { build: 'echo "build"' } }) }); const cp = run({ cwd, env: { NTL_RUNNER: "echo" } }); cp.assertNotStderrData(t); cp.getStdoutResult().then(res => { t.equal( readLastLine(res), "run build", "should env variable-defined custom runner" ); t.end(); }); cp.stdin.write("\n"); cp.stdin.end(); });
"lru-cache-fs": class { constructor({ max }) { t.equal(max, 10, "should use default cast cache max value");