Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2022-04-02 03:48:22 +0300
committerGar <wraithgar@github.com>2022-04-04 21:35:15 +0300
commitde4de302e3562721ed2d6410182d493c36974e37 (patch)
treee5846a3c3f2675a737791f31d2c33a0efcf0a93d /test
parentedbd884f6a1f077c7b4e1b7127b0a0f14ae065a0 (diff)
chore: remove mocks from completion tests
Diffstat (limited to 'test')
-rw-r--r--test/lib/commands/audit.js10
-rw-r--r--test/lib/commands/completion.js19
2 files changed, 18 insertions, 11 deletions
diff --git a/test/lib/commands/audit.js b/test/lib/commands/audit.js
index 8b79b02ba..1afb8d333 100644
--- a/test/lib/commands/audit.js
+++ b/test/lib/commands/audit.js
@@ -6,6 +6,9 @@ const util = require('util')
const zlib = require('zlib')
const gzip = util.promisify(zlib.gzip)
const path = require('path')
+const fs = require('fs')
+
+t.cleanSnapshot = str => str.replace(/packages in [0-9]+[a-z]+/g, 'packages in xxx')
const tree = {
'package.json': JSON.stringify({
@@ -114,7 +117,6 @@ t.test('audit fix', async t => {
tap: t,
registry: npm.config.get('registry'),
})
- // with fix
const manifest = registry.manifest({
name: 'test-dep-a',
packuments: [{ version: '1.0.0' }, { version: '1.0.1' }],
@@ -139,6 +141,12 @@ t.test('audit fix', async t => {
})
await npm.exec('audit', ['fix'])
t.matchSnapshot(joinedOutput())
+ const pkg = fs.readFileSync(path.join(npm.prefix, 'package-lock.json'), 'utf8')
+ t.matchSnapshot(pkg, 'lockfile has test-dep-a@1.0.1')
+ t.ok(
+ fs.existsSync(path.join(npm.prefix, 'node_modules', 'test-dep-a', 'fixed.txt')),
+ 'has test-dep-a@1.0.1 on disk'
+ )
})
t.test('completion', async t => {
diff --git a/test/lib/commands/completion.js b/test/lib/commands/completion.js
index d4e6f1199..6cc167755 100644
--- a/test/lib/commands/completion.js
+++ b/test/lib/commands/completion.js
@@ -6,20 +6,19 @@ const completionScript = fs
.readFileSync(path.resolve(__dirname, '../../../lib/utils/completion.sh'), { encoding: 'utf8' })
.replace(/^#!.*?\n/, '')
-const { load: _loadMockNpm } = require('../../fixtures/mock-npm')
+const { load: loadMockNpm } = require('../../fixtures/mock-npm')
const mockGlobals = require('../../fixtures/mock-globals')
const loadMockCompletion = async (t, o = {}) => {
- const { globals, windows, ...options } = o
+ const { globals = {}, windows, ...options } = o
let resetGlobals = {}
- if (globals) {
- resetGlobals = mockGlobals(t, globals).reset
- }
- const res = await _loadMockNpm(t, {
- mocks: {
- '../../lib/utils/is-windows.js': { isWindowsShell: !!windows },
- ...options.mocks,
- },
+ resetGlobals = mockGlobals(t, {
+ 'process.platform': windows ? 'win32' : 'posix',
+ 'process.env.term': 'notcygwin',
+ 'process.env.msystem': 'nogmingw',
+ ...globals,
+ }).reset
+ const res = await loadMockNpm(t, {
...options,
})
const completion = await res.npm.cmd('completion')