diff options
Diffstat (limited to 'deps/npm/test/lib/utils')
-rw-r--r-- | deps/npm/test/lib/utils/config/definitions.js | 9 | ||||
-rw-r--r-- | deps/npm/test/lib/utils/exit-handler.js | 6 | ||||
-rw-r--r-- | deps/npm/test/lib/utils/reify-output.js | 11 | ||||
-rw-r--r-- | deps/npm/test/lib/utils/update-notifier.js | 3 |
4 files changed, 18 insertions, 11 deletions
diff --git a/deps/npm/test/lib/utils/config/definitions.js b/deps/npm/test/lib/utils/config/definitions.js index bf4b48709a..a5b34a7499 100644 --- a/deps/npm/test/lib/utils/config/definitions.js +++ b/deps/npm/test/lib/utils/config/definitions.js @@ -929,3 +929,12 @@ t.test('lockfile version', t => { t.match(flat.lockfileVersion, 3, 'flattens to a number') t.end() }) + +t.test('loglevel silent', t => { + const flat = {} + definitions.loglevel.flatten('loglevel', { + loglevel: 'silent', + }, flat) + t.match(flat.silent, true, 'flattens to assign silent') + t.end() +}) diff --git a/deps/npm/test/lib/utils/exit-handler.js b/deps/npm/test/lib/utils/exit-handler.js index 54bf48f89b..6a96d92ddb 100644 --- a/deps/npm/test/lib/utils/exit-handler.js +++ b/deps/npm/test/lib/utils/exit-handler.js @@ -89,9 +89,9 @@ const mockExitHandler = async (t, { init, load, testdir, config } = {}) => { ...rest, errors, npm, - // // Make it async to make testing ergonomics a little - // // easier so we dont need to t.plan() every test to - // // make sure we get process.exit called + // Make it async to make testing ergonomics a little + // easier so we dont need to t.plan() every test to + // make sure we get process.exit called exitHandler: (...args) => new Promise(resolve => { process.once('exit', resolve) exitHandler(...args) diff --git a/deps/npm/test/lib/utils/reify-output.js b/deps/npm/test/lib/utils/reify-output.js index 4e9ed7133c..b38a14de33 100644 --- a/deps/npm/test/lib/utils/reify-output.js +++ b/deps/npm/test/lib/utils/reify-output.js @@ -1,9 +1,4 @@ const t = require('tap') -const log = require('../../../lib/utils/log-shim') - -const _level = log.level -t.beforeEach(() => log.level = 'warn') -t.teardown(() => log.level = _level) t.cleanSnapshot = str => str.replace(/in [0-9]+m?s/g, 'in {TIME}') @@ -13,6 +8,7 @@ const settings = { const npm = { started: Date.now(), flatOptions: settings, + silent: false, } const reifyOutput = require('../../../lib/utils/reify-output.js') t.test('missing info', (t) => { @@ -236,10 +232,13 @@ t.test('showing and not showing audit report', async t => { } t.test('no output when silent', t => { + t.teardown(() => { + delete npm.silent + }) + npm.silent = true npm.output = out => { t.fail('should not get output when silent', { actual: out }) } - log.level = 'silent' reifyOutput(npm, { actualTree: { inventory: { size: 999 }, children: [] }, auditReport, diff --git a/deps/npm/test/lib/utils/update-notifier.js b/deps/npm/test/lib/utils/update-notifier.js index a7a800c602..fa4af29476 100644 --- a/deps/npm/test/lib/utils/update-notifier.js +++ b/deps/npm/test/lib/utils/update-notifier.js @@ -84,12 +84,11 @@ t.afterEach(() => { }) const runUpdateNotifier = async ({ color = true, ...npmOptions } = {}) => { - const _npm = { ...defaultNpm, ...npmOptions } + const _npm = { ...defaultNpm, ...npmOptions, logColor: color } await t.mock('../../../lib/utils/update-notifier.js', { '@npmcli/ci-detect': () => ciMock, pacote, fs, - npmlog: { useColor: () => color }, })(_npm) return _npm.updateNotification } |