summaryrefslogtreecommitdiff
path: root/deps/npm/test/lib/npm.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/lib/npm.js')
-rw-r--r--deps/npm/test/lib/npm.js29
1 files changed, 14 insertions, 15 deletions
diff --git a/deps/npm/test/lib/npm.js b/deps/npm/test/lib/npm.js
index 62e48ce605..1a891e5ef1 100644
--- a/deps/npm/test/lib/npm.js
+++ b/deps/npm/test/lib/npm.js
@@ -1,9 +1,9 @@
const t = require('tap')
const { resolve, dirname, join } = require('path')
+const fs = require('@npmcli/fs')
const { load: loadMockNpm } = require('../fixtures/mock-npm.js')
const mockGlobals = require('../fixtures/mock-globals')
-const fs = require('@npmcli/fs')
// delete this so that we don't have configs from the fact that it
// is being run by 'npm test'
@@ -48,11 +48,10 @@ t.test('not yet loaded', async t => {
t.throws(() => npm.config.set('foo', 'bar'))
t.throws(() => npm.config.get('foo'))
t.same(logs, [])
- t.end()
})
t.test('npm.load', async t => {
- t.test('load error', async t => {
+ await t.test('load error', async t => {
const { npm } = await loadMockNpm(t, { load: false })
const loadError = new Error('load error')
npm.config.load = async () => {
@@ -76,8 +75,11 @@ t.test('npm.load', async t => {
})
t.test('basic loading', async t => {
- const { npm, logs, prefix: dir, cache } = await loadMockNpm(t, {
+ const { npm, logs, prefix: dir, cache, other } = await loadMockNpm(t, {
prefixDir: { node_modules: {} },
+ otherDirs: {
+ newCache: {},
+ },
})
t.equal(npm.loaded, true)
@@ -94,10 +96,9 @@ t.test('npm.load', async t => {
mockGlobals(t, { process: { platform: 'posix' } })
t.equal(resolve(npm.cache), resolve(cache), 'cache is cache')
- const newCache = t.testdir()
- npm.cache = newCache
- t.equal(npm.config.get('cache'), newCache, 'cache setter sets config')
- t.equal(npm.cache, newCache, 'cache getter gets new config')
+ npm.cache = other.newCache
+ t.equal(npm.config.get('cache'), other.newCache, 'cache setter sets config')
+ t.equal(npm.cache, other.newCache, 'cache getter gets new config')
t.equal(npm.lockfileVersion, 2, 'lockfileVersion getter')
t.equal(npm.prefix, npm.localPrefix, 'prefix is local prefix')
t.not(npm.prefix, npm.globalPrefix, 'prefix is not global prefix')
@@ -138,7 +139,7 @@ t.test('npm.load', async t => {
t.equal(tmp, npm.tmp, 'getter only generates it once')
})
- t.test('forceful loading', async t => {
+ await t.test('forceful loading', async t => {
const { logs } = await loadMockNpm(t, {
globals: {
'process.argv': [...process.argv, '--force', '--color', 'always'],
@@ -152,7 +153,7 @@ t.test('npm.load', async t => {
])
})
- t.test('node is a symlink', async t => {
+ await t.test('node is a symlink', async t => {
const node = process.platform === 'win32' ? 'node.exe' : 'node'
const { npm, logs, outputs, prefix } = await loadMockNpm(t, {
prefixDir: {
@@ -227,7 +228,7 @@ t.test('npm.load', async t => {
t.same(outputs, [['scope=@foo\n\u2010not-a-dash=undefined']])
})
- t.test('--no-workspaces with --workspace', async t => {
+ await t.test('--no-workspaces with --workspace', async t => {
const { npm } = await loadMockNpm(t, {
load: false,
prefixDir: {
@@ -262,7 +263,7 @@ t.test('npm.load', async t => {
)
})
- t.test('workspace-aware configs and commands', async t => {
+ await t.test('workspace-aware configs and commands', async t => {
const { npm, outputs } = await loadMockNpm(t, {
prefixDir: {
packages: {
@@ -318,7 +319,7 @@ t.test('npm.load', async t => {
)
})
- t.test('workspaces in global mode', async t => {
+ await t.test('workspaces in global mode', async t => {
const { npm } = await loadMockNpm(t, {
prefixDir: {
packages: {
@@ -500,7 +501,6 @@ t.test('timings', async t => {
t.notOk(npm.unfinishedTimers.has('foo'), 'foo timer is gone')
t.notOk(npm.unfinishedTimers.has('bar'), 'bar timer is gone')
t.match(npm.finishedTimers, { foo: Number, bar: Number, npm: Number })
- t.end()
})
t.test('writes timings file', async t => {
@@ -565,7 +565,6 @@ t.test('output clears progress and console.logs the message', async t => {
t.match(logs, [['hello']])
t.match(errors, [['error']])
- t.end()
})
t.test('aliases and typos', async t => {