MCPcopy Index your code
hub / github.com/nodejs/node / mockNpm

Function mockNpm

deps/npm/test/lib/commands/pkg.js:9–24  ·  view source on GitHub ↗
(t, { ...opts } = {})

Source from the content-addressed store, hash-verified

7t.cleanSnapshot = (str) => cleanCwd(str)
8
9const mockNpm = async (t, { ...opts } = {}) => {
10 const res = await _mockNpm(t, {
11 ...opts,
12 command: 'pkg',
13 })
14
15 const readPackageJson = (dir = '') =>
16 JSON.parse(readFileSync(resolve(res.prefix, dir, 'package.json'), 'utf8'))
17
18 return {
19 ...res,
20 pkg: (...args) => res.npm.exec('pkg', args),
21 readPackageJson,
22 OUTPUT: () => res.joinedOutput(),
23 }
24}
25
26t.test('no args', async t => {
27 const { pkg } = await mockNpm(t)

Callers 15

mockLsFunction · 0.70
ls.jsFile · 0.70
mockProfileFunction · 0.70
explore.jsFile · 0.70
mockExploreFunction · 0.70
mockRsFunction · 0.70
explain.jsFile · 0.70
mockExplainFunction · 0.70
mockTeamFunction · 0.70
mockLinkFunction · 0.70
link.jsFile · 0.70
pkg.jsFile · 0.70

Calls 1

execMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…