test('correctly log Infinity', async (t) => { const stream = sink() const instance = pino(stream) const o = { num: Infinity } instance.info(o) const { num } = await once(stream, 'data') t.is(num, null) })
test('fast-safe-stringify must be used when interpolating', async (t) => { const stream = sink() const instance = pino(stream) const o = { a: { b: {} } } o.a.b.c = o.a.b instance.info('test %j', o) const { msg } = await once(stream, 'data') t.is(msg, 'test {"a":{"b":{"c":"[Circular]"}}}') })
test('mention npm fund upon installing single dependency', function (t) { setup(t) common.npm(['install', '--no-save', singlePackage], {cwd: base}, function (err, code, stdout, stderr) { if (err) throw err t.is(code, 0, 'installed successfully') t.is(stderr, '', 'no warnings') t.includes(stdout, '1 package is looking for funding', 'should print amount of packages needing funding') t.includes(stdout, ' run `npm fund` for details', 'should print npm fund mention') t.end() }) })
test('package-lock.json unformatted, package.json formatted when config has `format-package-lock: false`', function (t) { setup() common.npm(['install'], {cwd: testdir, env}).spread((code, stdout, stderr) => { t.is(code, 0, 'ok') t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created') const pkgLockUtf8 = fs.readFileSync(pkgLockPath, 'utf-8') t.equal(pkgLockUtf8.split(CRLFreg).length, 2, 'package-lock.json is unformatted') const pkgUtf8 = fs.readFileSync(pkgPath, 'utf-8') t.notEqual(pkgUtf8.split(CRLFreg).length, 2, 'package.json is formatted') t.done() }) })
test('install', function (t) { common.npm(['install', '--no-save', './b-src'], {cwd: testdir}, function (err, code, stdout, stderr) { if (err) throw err t.is(code, 0, 'installed successfully') t.is(stderr, '', 'no warnings') t.includes(stdout, 'added 1 package from 2 contributors', 'lists number of unique contributors') t.end() }) })
test('mention packages looking for funding using --json', function (t) { setup(t) common.npm(['install', '--no-save', '--json', multiplePackages], {cwd: base}, function (err, code, stdout, stderr) { if (err) throw err t.is(code, 0, 'installed successfully') t.is(stderr, '', 'no warnings') const res = JSON.parse(stdout) t.match(res.funding, '4 packages are looking for funding', 'should print amount of packages needing funding') t.end() }) })
test('npm-shrinkwrap.json formatted when config has `format-package-lock: true`', function (t) { setup() common.npm(['shrinkwrap'], {cwd: testdir}).spread((code, stdout, stderr) => { t.is(code, 0, 'ok') t.ok(fs.existsSync(shrinkwrapPath), 'ensure that npm-shrinkwrap.json was created') const shrinkwrapUtf8 = fs.readFileSync(shrinkwrapPath, 'utf-8') t.notEqual(shrinkwrapUtf8.split(CRLFreg).length, 2, 'npm-shrinkwrap.json is unformatted') t.done() }) })
test('skips mention npm fund using --no-fund option', function (t) { setup(t) common.npm(['install', '--no-save', '--no-fund', multiplePackages], {cwd: base}, function (err, code, stdout, stderr) { if (err) throw err t.is(code, 0, 'installed successfully') t.is(stderr, '', 'no warnings') t.doesNotHave(stdout, '4 packages are looking for funding', 'should print amount of packages needing funding') t.doesNotHave(stdout, ' run `npm fund` for details', 'should print npm fund mention') t.end() }) })
test('npm-shrinkwrap.json unformatted when config has `format-package-lock: false`', function (t) { setup() common.npm(['shrinkwrap'], {cwd: testdir, env}).spread((code, stdout, stderr) => { t.is(code, 0, 'ok') t.ok(fs.existsSync(shrinkwrapPath), 'ensure that npm-shrinkwrap.json was created') const shrinkwrapUtf8 = fs.readFileSync(shrinkwrapPath, 'utf-8') t.equal(shrinkwrapUtf8.split(CRLFreg).length, 2, 'npm-shrinkwrap.json is unformatted') t.done() }) })
test('package-lock.json and package.json formatted when config has `format-package-lock: true`', function (t) { setup() common.npm(['install'], {cwd: testdir}).spread((code, stdout, stderr) => { t.is(code, 0, 'ok') t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created') const pkgLockUtf8 = fs.readFileSync(pkgLockPath, 'utf-8') t.notEqual(pkgLockUtf8.split(CRLFreg).length, 2, 'package-lock.json is formatted') const pkgUtf8 = fs.readFileSync(pkgPath, 'utf-8') t.notEqual(pkgUtf8.split(CRLFreg).length, 2, 'package.json is formatted') t.done() }) })
test('correctly log -Infinity', async (t) => { const stream = sink() const instance = pino(stream) const o = { num: -Infinity } instance.info(o) const { num } = await once(stream, 'data') t.is(num, null) })
test('correctly log NaN', async (t) => { const stream = sink() const instance = pino(stream) const o = { num: NaN } instance.info(o) const { num } = await once(stream, 'data') t.is(num, null) })
test('mention npm fund upon installing multiple dependencies', function (t) { setup(t) common.npm(['install', '--no-save', multiplePackages], {cwd: base}, function (err, code, stdout, stderr) { if (err) throw err t.is(code, 0, 'installed successfully') t.is(stderr, '', 'no warnings') t.includes(stdout, '4 packages are looking for funding', 'should print amount of packages needing funding') t.includes(stdout, ' run `npm fund` for details', 'should print npm fund mention') t.end() }) })