diff options
author | Gar <gar+gh@danger.computer> | 2021-09-15 21:29:13 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-10-07 19:07:19 +0300 |
commit | a13d9d53ddf3e0f52f4a39fe116653bf40cf99e5 (patch) | |
tree | c281324e40798b6e8e1ed53a9a2d55dd8f87b91a /test | |
parent | 32e163fd10aace69d927dae46d04d64c04e5014b (diff) |
feat: drop node 10, 11, and programmatic api
BREAKING CHANGE:
- Drop official support for node versions less than v12.
- Drop support for `require('npm')`
- Update a few subdependencies that dropped node10 support, and brought
in the latest node-gyp
PR-URL: https://github.com/npm/cli/pull/3762
Credit: @wraithgar
Close: #3762
Reviewed-by: @fritzy
Diffstat (limited to 'test')
-rw-r--r-- | test/coverage-map.js | 2 | ||||
-rw-r--r-- | test/index.js | 23 | ||||
-rw-r--r-- | test/lib/npm.js | 39 | ||||
-rw-r--r-- | test/lib/utils/unsupported.js | 13 |
4 files changed, 56 insertions, 21 deletions
diff --git a/test/coverage-map.js b/test/coverage-map.js index 63f2a608e..aff7a6527 100644 --- a/test/coverage-map.js +++ b/test/coverage-map.js @@ -11,7 +11,7 @@ const coverageMap = (filename) => { // this one doesn't provide any coverage nyc can track return [] } - if (/^test\/(lib|bin)\//.test(filename)) + if (/^test\/(lib\/|bin\/|index\.js$)/.test(filename)) return filename.replace(/^test\//, '') return [] } diff --git a/test/index.js b/test/index.js new file mode 100644 index 000000000..11dd5eb2d --- /dev/null +++ b/test/index.js @@ -0,0 +1,23 @@ +const t = require('tap') +const index = require.resolve('../index.js') +const packageIndex = require.resolve('../') +t.equal(index, packageIndex, 'index is main package require() export') +t.throws(() => require(index), { + message: 'The programmatic API was removed in npm v8.0.0', +}) + +t.test('loading as main module will load the cli', t => { + const { spawn } = require('child_process') + const LS = require('../lib/ls.js') + const ls = new LS({}) + const p = spawn(process.execPath, [index, 'ls', '-h']) + const out = [] + p.stdout.on('data', c => out.push(c)) + p.on('close', (code, signal) => { + t.equal(code, 0) + t.equal(signal, null) + t.match(Buffer.concat(out).toString(), ls.usage) + t.end() + }) +}) + diff --git a/test/lib/npm.js b/test/lib/npm.js index 03bb46d8d..7d6176247 100644 --- a/test/lib/npm.js +++ b/test/lib/npm.js @@ -412,22 +412,6 @@ t.test('npm.load', t => { t.end() }) -t.test('loading as main will load the cli', t => { - const { spawn } = require('child_process') - const npm = require.resolve('../../lib/npm.js') - const LS = require('../../lib/ls.js') - const ls = new LS({}) - const p = spawn(process.execPath, [npm, 'ls', '-h']) - const out = [] - p.stdout.on('data', c => out.push(c)) - p.on('close', (code, signal) => { - t.equal(code, 0) - t.equal(signal, null) - t.match(Buffer.concat(out).toString(), ls.usage) - t.end() - }) -}) - t.test('set process.title', t => { t.test('basic title setting', async t => { process.argv = [ @@ -501,3 +485,26 @@ t.test('timings', t => { t.match(npm.timings, { foo: Number, bar: Number }) t.end() }) + +t.test('output clears progress and console.logs the message', t => { + const npm = require('../../lib/npm.js') + const logs = [] + const { log } = console + const { log: { clearProgress, showProgress } } = npm + let showingProgress = true + npm.log.clearProgress = () => showingProgress = false + npm.log.showProgress = () => showingProgress = true + console.log = (...args) => { + t.equal(showingProgress, false, 'should not be showing progress right now') + logs.push(args) + } + t.teardown(() => { + console.log = log + npm.log.showProgress = showProgress + npm.log.clearProgress = clearProgress + }) + + npm.output('hello') + t.strictSame(logs, [['hello']]) + t.end() +}) diff --git a/test/lib/utils/unsupported.js b/test/lib/utils/unsupported.js index 3a05d9066..4d806cefc 100644 --- a/test/lib/utils/unsupported.js +++ b/test/lib/utils/unsupported.js @@ -27,10 +27,15 @@ const versions = [ ['v7.2.3', false, true], ['v8.4.0', false, true], ['v9.3.0', false, true], - ['v10.0.0-0', false, false], - ['v11.0.0-0', false, false], - ['v12.0.0-0', false, false], - ['v13.0.0-0', false, false], + ['v10.0.0-0', false, true], + ['v11.0.0-0', false, true], + ['v12.0.0-0', false, true], + ['v12.13.0-0', false, false], + ['v13.0.0-0', false, true], + ['v14.0.0-0', false, true], + ['v14.15.0-0', false, false], + ['v15.0.0-0', false, true], + ['v16.0.0-0', false, false], ] t.test('versions', function (t) { |