diff options
author | Gar <gar+gh@danger.computer> | 2022-03-03 07:41:38 +0300 |
---|---|---|
committer | Ruy Adorno <ruyadorno@hotmail.com> | 2022-03-10 18:40:11 +0300 |
commit | 0da59186e5a78bbcf47c440289241e9f85ff3eba (patch) | |
tree | 72af61cff54a384283f2d2d9e1a462db98396bb6 /test | |
parent | d521a25db2b19239a8d7a66a4e10f30dc15e7cf0 (diff) |
chore: rewrite doctor tests
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/clean-snapshot.js | 2 | ||||
-rw-r--r-- | test/fixtures/mock-logs.js | 22 | ||||
-rw-r--r-- | test/fixtures/mock-npm.js | 4 | ||||
-rw-r--r-- | test/fixtures/tnock.js | 15 | ||||
-rw-r--r-- | test/lib/commands/doctor.js | 1379 |
5 files changed, 449 insertions, 973 deletions
diff --git a/test/fixtures/clean-snapshot.js b/test/fixtures/clean-snapshot.js index 037155eea..b0ea28cee 100644 --- a/test/fixtures/clean-snapshot.js +++ b/test/fixtures/clean-snapshot.js @@ -10,7 +10,7 @@ const cleanCwd = (path) => normalizePath(path) .replace(new RegExp(normalizePath(process.cwd()), 'g'), '{CWD}') const cleanDate = (str) => - str.replace(/\d{4}-\d{2}-\d{2}T\d{2}[_:]\d{2}[_:]\d{2}[_:]\d{3}Z/g, '{DATE}') + str.replace(/\d{4}-\d{2}-\d{2}T\d{2}[_:]\d{2}[_:]\d{2}[_:.]\d{3}Z/g, '{DATE}') module.exports = { normalizePath, diff --git a/test/fixtures/mock-logs.js b/test/fixtures/mock-logs.js index 80037c6ff..706c9a305 100644 --- a/test/fixtures/mock-logs.js +++ b/test/fixtures/mock-logs.js @@ -60,7 +60,27 @@ const mockLogs = (otherMocks = {}) => { return acc }, {}), // except collect timing logs - { timing: (...args) => logs.push(['timing', ...args]) }, + { + timing: (...args) => logs.push(['timing', ...args]), + newItem: () => { + return { + info: (...p) => { + logs.push(['info', ...p]) + }, + warn: (...p) => { + logs.push(['warn', ...p]) + }, + error: (...p) => { + logs.push(['error', ...p]) + }, + silly: (...p) => { + logs.push(['silly', ...p]) + }, + completeWork: () => {}, + finish: () => {}, + } + }, + }, otherMocks.npmlog )), } diff --git a/test/fixtures/mock-npm.js b/test/fixtures/mock-npm.js index b00f072dc..ea608d664 100644 --- a/test/fixtures/mock-npm.js +++ b/test/fixtures/mock-npm.js @@ -51,7 +51,7 @@ const LoadMockNpm = async (t, { load = init, prefixDir = {}, cacheDir = {}, - globalDir = {}, + globalPrefixDir = {}, config = {}, mocks = {}, globals = null, @@ -79,7 +79,7 @@ const LoadMockNpm = async (t, { // Set log level as early as possible since setLoglevel(t, config.loglevel) - const dir = t.testdir({ prefix: prefixDir, cache: cacheDir, global: globalDir }) + const dir = t.testdir({ prefix: prefixDir, cache: cacheDir, global: globalPrefixDir }) const prefix = path.join(dir, 'prefix') const cache = path.join(dir, 'cache') const globalPrefix = path.join(dir, 'global') diff --git a/test/fixtures/tnock.js b/test/fixtures/tnock.js new file mode 100644 index 000000000..c5acec510 --- /dev/null +++ b/test/fixtures/tnock.js @@ -0,0 +1,15 @@ +'use strict' + +const nock = require('nock') + +// TODO (other tests actually make network calls today, which is bad) +// nock.disableNetConnect() + +module.exports = tnock +function tnock (t, host) { + const server = nock(host) + t.teardown(function () { + server.done() + }) + return server +} diff --git a/test/lib/commands/doctor.js b/test/lib/commands/doctor.js index dee2110ff..25c3bea0d 100644 --- a/test/lib/commands/doctor.js +++ b/test/lib/commands/doctor.js @@ -1,1022 +1,463 @@ const t = require('tap') - -const { join } = require('path') +const { load: loadMockNpm } = require('../../fixtures/mock-npm') +const tnock = require('../../fixtures/tnock.js') const fs = require('fs') -const ansiTrim = require('../../../lib/utils/ansi-trim.js') + +const { cleanCwd, cleanDate } = require('../../fixtures/clean-snapshot.js') + +const cleanCacheSha = (str) => + str.replace(/content-v2\/sha512\/[^"]+/g, 'content-v2/sha512/{sha}') + +t.cleanSnapshot = p => cleanCacheSha(cleanDate(cleanCwd(p))) + +// TODO mockglobals! const isWindows = require('../../../lib/utils/is-windows.js') -const { fake: mockNpm } = require('../../fixtures/mock-npm') + +const processVersion = process.version +// TODO mockglobals! +t.beforeEach(() => { + Object.defineProperty(process, 'version', { value: 'v1.0.0' }) +}) + +const consoleErrorFn = console.error +let consoleError = false +console.error = () => { + consoleError = true +} +t.teardown(() => { + Object.defineProperty(process, 'version', { value: processVersion }) + console.error = consoleErrorFn +}) + +t.afterEach(() => { + consoleError = false +}) // getuid and getgid do not exist in windows, so we shim them // to return 0, as that is the value that lstat will assign the // gid and uid properties for fs.Stats objects +// TODO mockglobals! if (isWindows) { process.getuid = () => 0 process.getgid = () => 0 } -const output = [] - -let pingError -const ping = async () => { - if (pingError) { - throw pingError - } -} - -let whichError = null -const which = async () => { - if (whichError) { - throw whichError +const npmManifest = (version) => { + return { + name: 'npm', + versions: { + [version]: { + name: 'npm', + version: version, + }, + }, + time: { + [version]: new Date(), + }, + 'dist-tags': { latest: version }, } - return '/path/to/git' } const nodeVersions = [ - { version: 'v14.0.0', lts: false }, - { version: 'v13.0.0', lts: false }, - // it's necessary to allow tests in node 10.x to not mark 12.x as lts - { version: 'v12.0.0', lts: false }, - { version: 'v10.13.0', lts: 'Dubnium' }, + { version: 'v2.0.1', lts: false }, + { version: 'v2.0.0', lts: false }, + { version: 'v1.0.0', lts: 'NpmTestium' }, ] -const fetch = async () => { - return { - json: async () => { - return nodeVersions +const dirs = { + prefixDir: { + node_modules: { + testLink: t.fixture('symlink', './testDir'), + testDir: { + testFile: 'test contents', + }, + '.bin': {}, }, - } -} - -const logs = { - info: [], -} - -const clearLogs = () => { - output.length = 0 - for (const key in logs) { - if (Array.isArray(logs[key])) { - logs[key].length = 0 - } else { - delete logs[key] - } - } -} - -const npm = mockNpm({ - flatOptions: { - registry: 'https://registry.npmjs.org/', - }, - config: { - loglevel: 'info', }, - version: '7.1.0', - output: data => { - output.push(data) - }, -}) - -let latestNpm = npm.version -const pacote = { - manifest: async () => { - return { version: latestNpm } - }, -} - -let verifyResponse = { verifiedCount: 1, verifiedContent: 1 } -const cacache = { - verify: async () => { - return verifyResponse + globalPrefixDir: { + bin: {}, + lib: { + node_modules: { + }, + }, }, } const mocks = { - '../../../lib/utils/is-windows.js': false, - '../../../lib/utils/ping.js': ping, - cacache, - pacote, - 'make-fetch-happen': fetch, - which, - 'proc-log': { - info: msg => { - logs.info.push(msg) - }, - }, - npmlog: { - newItem: name => { - logs[name] = {} - return { - info: (_, msg) => { - if (!logs[name].info) { - logs[name].info = [] - } - logs[name].info.push(msg) - }, - warn: (_, msg) => { - if (!logs[name].warn) { - logs[name].warn = [] - } - logs[name].warn.push(msg) - }, - error: (_, msg) => { - if (!logs[name].error) { - logs[name].error = [] - } - logs[name].error.push(msg) - }, - silly: (_, msg) => { - if (!logs[name].silly) { - logs[name].silly = [] - } - logs[name].silly.push(msg) - }, - completeWork: () => {}, - finish: () => { - logs[name].finished = true - }, - } - }, - level: 'error', - levels: { - info: 1, - error: 0, + '../../package.json': { version: '1.0.0' }, + '../../lib/utils/is-windows.js': false, + which: async () => '/path/to/git', + cacache: { + verify: () => { + return { badContentCount: 0, reclaimedCount: 0, missingContent: 0, verifiedContent: 0 } }, }, - } -const Doctor = t.mock('../../../lib/commands/doctor.js', { - ...mocks, +t.test('all clear', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await npm.exec('doctor', []) + t.matchSnapshot(joinedOutput(), 'output') + t.notOk(consoleError, 'console.error not called') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') }) -const doctor = new Doctor(npm) - -const origVersion = process.version -t.test('node versions', t => { - t.plan(nodeVersions.length) - - nodeVersions.forEach(({ version }) => { - t.test(`${version}:`, vt => { - Object.defineProperty(process, 'version', { value: version }) - vt.teardown(() => { - Object.defineProperty(process, 'version', { value: origVersion }) - }) - - vt.test(`${version}: npm doctor checks ok`, async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - clearLogs() - }) - - await doctor.exec([]) - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) - - vt.test('npm doctor supports silent', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - npm.config.set('loglevel', 'silent') - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - npm.config.set('loglevel', 'info') - clearLogs() - }) - - await doctor.exec([]) - - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.strictSame(output, [], 'did not print output') - }) - - vt.test('npm doctor supports color', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - npm.color = true - pingError = { message: 'generic error' } - const _consoleError = console.error - console.error = () => {} - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - delete npm.color - pingError = null - console.error = _consoleError - clearLogs() - }) - - await st.rejects(doctor.exec([]), /Some problems found/, 'detected the ping error') - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping.*not ok/, 'ping output is ok') - st.match(output, /npm -v.*ok/, 'npm -v output is ok') - st.match(output, /node -v.*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry.*ok.*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git.*ok/, 'which git output is ok') - st.match(output, /cached files.*ok/, 'cached files are ok') - st.match(output, /local node_modules.*ok/, 'local node_modules are ok') - st.match(output, /global node_modules.*ok/, 'global node_modules are ok') - st.match(output, /local bin folder.*ok/, 'local bin is ok') - st.match(output, /global bin folder.*ok/, 'global bin is ok') - st.match(output, /cache contents.*ok/, 'cache contents is ok') - st.not(output[0], ansiTrim(output[0]), 'output should contain color codes') - }) - - vt.test('npm doctor skips some tests in windows', async st => { - const WinDoctor = t.mock('../../../lib/commands/doctor.js', { - ...mocks, - '../../../lib/utils/is-windows.js': true, - }) - const winDoctor = new WinDoctor(npm) - - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - clearLogs() - }) - - await winDoctor.exec([]) - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: undefined, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) - - vt.test('npm doctor ping error E{3}', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - pingError = { code: 'E111', message: 'this error is 111' } - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - pingError = null - console.error = consoleError - clearLogs() - }) - - await st.rejects(doctor.exec([]), /Some problems found/, 'detected the ping error') - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match( - output, - /npm ping\s*not ok\s*111 this error is 111/, - 'ping output contains trimmed error' - ) - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) - - vt.test('npm doctor generic ping error', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - pingError = { message: 'generic error' } - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - pingError = null - console.error = consoleError - clearLogs() - }) - - await st.rejects(doctor.exec([]), /Some problems found/, 'detected the ping error') - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*not ok\s*generic error/, 'ping output contains trimmed error') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) - - vt.test('npm doctor outdated npm version', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - latestNpm = '7.1.1' - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - latestNpm = npm.version - console.error = consoleError - clearLogs() - }) - await st.rejects(doctor.exec([]), /Some problems found/, 'detected the out of date npm') - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*not ok/, 'npm -v output is not ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) - - vt.test('npm doctor file permission checks', async st => { - const dir = st.testdir({ - cache: { - one: 'one', - link: st.fixture('symlink', './baddir'), - unreadable: 'unreadable', - baddir: {}, - }, - local: { - two: 'two', - notmine: 'notmine', - }, - global: { - three: 'three', - broken: 'broken', - }, - localBin: { - four: 'four', - five: 'five', - }, - globalBin: { - six: 'six', - seven: 'seven', - }, - }) - - const _fsLstat = fs.lstat - fs.lstat = (p, cb) => { - let err = null - let stat = null - - try { - stat = fs.lstatSync(p) - } catch (err) { - return cb(err) - } - - switch (p) { - case join(dir, 'local', 'notmine'): - stat.uid += 1 - stat.gid += 1 - break - case join(dir, 'global', 'broken'): - err = new Error('broken') - break - } - - return cb(err, stat) - } - - const _fsReaddir = fs.readdir - fs.readdir = (p, cb) => { - let err = null - let result = null - - try { - result = fs.readdirSync(p) - } catch (err) { - return cb(err) - } - - if (p === join(dir, 'cache', 'baddir')) { - err = new Error('broken') - } - - return cb(err, result) - } - - const _fsAccess = fs.access - fs.access = (p, mask, cb) => { - const err = new Error('failed') - switch (p) { - case join(dir, 'cache', 'unreadable'): - case join(dir, 'localBin', 'four'): - case join(dir, 'globalBin', 'six'): - return cb(err) - default: - return cb(null) - } - } - - const Doctor = t.mock('../../../lib/commands/doctor.js', { - ...mocks, - fs, - }) - const doctor = new Doctor(npm) - // it's necessary to allow tests in node 10.x to not mark 12.x as lted - - npm.cache = npm.flatOptions.cache = join(dir, 'cache') - npm.localDir = join(dir, 'local') - npm.globalDir = join(dir, 'global') - npm.localBin = join(dir, 'localBin') - npm.globalBin = join(dir, 'globalBin') - const _consoleError = console.error - console.error = () => {} - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - console.error = _consoleError - fs.lstat = _fsLstat - fs.readdir = _fsReaddir - fs.access = _fsAccess - clearLogs() - }) - - await st.rejects(doctor.exec([]), /Some problems found/, 'identified problems') - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [join(dir, 'cache')]: { finished: true }, - [join(dir, 'local')]: { finished: true }, - [join(dir, 'global')]: { finished: true }, - [join(dir, 'localBin')]: { finished: true }, - [join(dir, 'globalBin')]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*not ok/, 'cached files are not ok') - st.match(output, /local node_modules\s*not ok/, 'local node_modules are not ok') - st.match(output, /global node_modules\s*not ok/, 'global node_modules are not ok') - st.match(output, /local bin folder\s*not ok/, 'local bin is not ok') - st.match(output, /global bin folder\s*not ok/, 'global bin is not ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) - - vt.test('npm doctor missing git', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - whichError = new Error('boom') - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - whichError = null - console.error = consoleError - clearLogs() - }) - - await st.rejects(doctor.exec([]), /Some problems found/, 'detected the missing git') - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*not ok/, 'which git output is not ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) - - vt.test('npm doctor cache verification showed bad content', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - const _verifyResponse = verifyResponse - verifyResponse = { - ...verifyResponse, - badContentCount: 1, - } - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} - - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - verifyResponse = _verifyResponse - console.error = consoleError - clearLogs() - }) +t.test('all clear in color', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + npm.config.set('color', 'always') + await npm.exec('doctor', []) + t.matchSnapshot(joinedOutput(), 'everything is ok in color') + t.notOk(consoleError, 'console.error not called') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - // cache verification problems get fixed and so do not throw an error - await doctor.exec([]) - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is not ok') - }) +t.test('silent', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + config: { + loglevel: 'silent', + }, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await npm.exec('doctor', []) + t.matchSnapshot(joinedOutput(), 'output') + t.notOk(consoleError, 'console.error not called') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) +t.test('ping 404', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(404, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'ping 404') + t.ok(consoleError, 'console.error called') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - vt.test('npm doctor cache verification showed reclaimed content', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - const _verifyResponse = verifyResponse - verifyResponse = { - ...verifyResponse, - reclaimedCount: 1, - reclaimedSize: 100, - } - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} +t.test('ping 404 in color', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(404, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + npm.config.set('color', 'always') + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'ping 404 in color') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - verifyResponse = _verifyResponse - console.error = consoleError - clearLogs() - }) +t.test('ping exception with code', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').replyWithError({ message: 'Test Error', code: 'TEST' }) + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'ping failure') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - // cache verification problems get fixed and so do not throw an error - await doctor.exec([]) +t.test('ping exception without code', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').replyWithError({ message: 'Test Error', code: false }) + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'ping failure') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is not ok') - }) +t.test('npm out of date', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest('2.0.0')) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'npm is out of date') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - vt.test('npm doctor cache verification showed missing content', async st => { - const dir = t.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - const _verifyResponse = verifyResponse - verifyResponse = { - ...verifyResponse, - missingContent: 1, - } - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} +t.test('node out of date - lts', async t => { + Object.defineProperty(process, 'version', { value: 'v0.0.1' }) + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'node is out of date') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - verifyResponse = _verifyResponse - console.error = consoleError - clearLogs() - }) +t.test('node out of date - current', async t => { + Object.defineProperty(process, 'version', { value: 'v2.0.0' }) + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'node is out of date') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - // cache verification problems get fixed and so do not throw an error - await doctor.exec([]) - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is not ok') - }) +t.test('non-default registry', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + config: { registry: 'http://some-other-url.npmjs.org' }, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'non default registry') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - vt.test('npm doctor not using default registry', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - const _currentRegistry = npm.flatOptions.registry - npm.flatOptions.registry = 'https://google.com' - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} +t.test('missing git', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + which: async () => { + throw new Error('test error') + }, + }, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'missing git') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - npm.flatOptions.registry = _currentRegistry - console.error = consoleError - clearLogs() - }) +t.test('windows skips permissions checks', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + '../../lib/utils/is-windows.js': true, + }, + prefixDir: {}, + globalPrefixDir: {}, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await npm.exec('doctor', []) + t.matchSnapshot(joinedOutput(), 'no permissions checks') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - await st.rejects( - doctor.exec([]), - /Some problems found/, - 'detected the non-default registry' - ) - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, - }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*ok/, 'node -v output is ok') - st.match( - output, - /npm config get registry\s*not ok/, - 'npm config get registry output is not ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') - }) +t.test('missing global directories', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + prefixDir: dirs.prefixDir, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'missing global directories') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - vt.end() - }) +t.test('incorrect owner', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + fs: { + ...fs, + lstat: (p, cb) => { + const stat = fs.lstatSync(p) + stat.uid += 1 + stat.gid += 1 + return cb(null, stat) + }, + }, + }, + ...dirs, }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'incorrect owner') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') }) -t.test('outdated node version', vt => { - vt.plan(1) - const version = 'v10.0.0' +t.test('incorrect permissions', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + fs: { + ...fs, + access: () => { + throw new Error('Test Error') + }, + }, + }, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'incorrect owner') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - Object.defineProperty(process, 'version', { value: version }) - vt.teardown(() => { - Object.defineProperty(process, 'version', { value: origVersion }) +t.test('error reading directory', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + fs: { + ...fs, + readdir: () => { + throw new Error('Test Error') + }, + }, + }, + ...dirs, }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await t.rejects(npm.exec('doctor', [])) + t.matchSnapshot(joinedOutput(), 'readdir error') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - vt.test('npm doctor outdated nodejs version', async st => { - const dir = st.testdir() - npm.cache = npm.flatOptions.cache = dir - npm.localDir = dir - npm.globalDir = dir - npm.localBin = dir - npm.globalBin = dir - nodeVersions.push({ version: process.version.replace(/\d+(-.*)?$/, '999'), lts: false }) - const consoleError = console.error - // we just print an empty line here, so swallow it and ignore - console.error = () => {} +t.test('cacache badContent', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + cacache: { + verify: async () => { + return { badContentCount: 1, reclaimedCount: 0, missingContent: 0, verifiedContent: 2 } + }, + }, + }, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await npm.exec('doctor', []) + t.matchSnapshot(joinedOutput(), 'corrupted cache content') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - st.teardown(() => { - delete npm.cache - delete npm.flatOptions.cache - delete npm.localDir - delete npm.globalDir - delete npm.localBin - delete npm.globalBin - nodeVersions.pop() - console.error = consoleError - clearLogs() - }) +t.test('cacache reclaimedCount', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + cacache: { + verify: async () => { + return { badContentCount: 0, reclaimedCount: 1, missingContent: 0, verifiedContent: 2 } + }, + }, + }, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await npm.exec('doctor', []) + t.matchSnapshot(joinedOutput(), 'content garbage collected') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) - await st.rejects(doctor.exec([]), /Some problems found/, 'detected the out of date nodejs') - st.match( - logs, - { - checkPing: { finished: true }, - getLatestNpmVersion: { finished: true }, - getLatestNodejsVersion: { finished: true }, - getGitPath: { finished: true }, - [dir]: { finished: true }, - verifyCachedFiles: { finished: true }, +t.test('cacache missingContent', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks: { + ...mocks, + cacache: { + verify: async () => { + return { badContentCount: 0, reclaimedCount: 0, missingContent: 1, verifiedContent: 2 } + }, }, - 'trackers all finished' - ) - st.match(output, /npm ping\s*ok/, 'ping output is ok') - st.match(output, /npm -v\s*ok/, 'npm -v output is ok') - st.match(output, /node -v\s*not ok/, 'node -v output is not ok') - st.match( - output, - /npm config get registry\s*ok\s*using default/, - 'npm config get registry output is ok' - ) - st.match(output, /which git\s*ok/, 'which git output is ok') - st.match(output, /cached files\s*ok/, 'cached files are ok') - st.match(output, /local node_modules\s*ok/, 'local node_modules are ok') - st.match(output, /global node_modules\s*ok/, 'global node_modules are ok') - st.match(output, /local bin folder\s*ok/, 'local bin is ok') - st.match(output, /global bin folder\s*ok/, 'global bin is ok') - st.match(output, /cache contents\s*ok/, 'cache contents is ok') + }, + ...dirs, }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await npm.exec('doctor', []) + t.matchSnapshot(joinedOutput(), 'missing content') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') }) |