11cb0ef41Sopenharmony_ci// TODO(isaacs): This test has a lot of very large objects pasted inline.
21cb0ef41Sopenharmony_ci// Consider using t.matchSnapshot on these instead, especially since many
31cb0ef41Sopenharmony_ci// of them contain the tap testdir folders, which are auto-generated and
41cb0ef41Sopenharmony_ci// may change when node-tap is updated.
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst t = require('tap')
71cb0ef41Sopenharmony_ciconst { utimesSync } = require('fs')
81cb0ef41Sopenharmony_ciconst mockNpm = require('../../fixtures/mock-npm.js')
91cb0ef41Sopenharmony_ciconst { cleanCwd } = require('../../fixtures/clean-snapshot')
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst touchHiddenPackageLock = prefix => {
121cb0ef41Sopenharmony_ci  const later = new Date(Date.now() + 10000)
131cb0ef41Sopenharmony_ci  utimesSync(`${prefix}/node_modules/.package-lock.json`, later, later)
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cit.cleanSnapshot = str => cleanCwd(str)
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciconst simpleNmFixture = {
191cb0ef41Sopenharmony_ci  node_modules: {
201cb0ef41Sopenharmony_ci    foo: {
211cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
221cb0ef41Sopenharmony_ci        name: 'foo',
231cb0ef41Sopenharmony_ci        version: '1.0.0',
241cb0ef41Sopenharmony_ci        dependencies: {
251cb0ef41Sopenharmony_ci          dog: '^1.0.0',
261cb0ef41Sopenharmony_ci        },
271cb0ef41Sopenharmony_ci      }),
281cb0ef41Sopenharmony_ci    },
291cb0ef41Sopenharmony_ci    dog: {
301cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
311cb0ef41Sopenharmony_ci        name: 'dog',
321cb0ef41Sopenharmony_ci        version: '1.0.0',
331cb0ef41Sopenharmony_ci      }),
341cb0ef41Sopenharmony_ci    },
351cb0ef41Sopenharmony_ci    chai: {
361cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
371cb0ef41Sopenharmony_ci        name: 'chai',
381cb0ef41Sopenharmony_ci        version: '1.0.0',
391cb0ef41Sopenharmony_ci      }),
401cb0ef41Sopenharmony_ci    },
411cb0ef41Sopenharmony_ci  },
421cb0ef41Sopenharmony_ci}
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ciconst diffDepTypesNmFixture = {
451cb0ef41Sopenharmony_ci  node_modules: {
461cb0ef41Sopenharmony_ci    'dev-dep': {
471cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
481cb0ef41Sopenharmony_ci        name: 'dev-dep',
491cb0ef41Sopenharmony_ci        description: 'A DEV dep kind of dep',
501cb0ef41Sopenharmony_ci        version: '1.0.0',
511cb0ef41Sopenharmony_ci        dependencies: {
521cb0ef41Sopenharmony_ci          foo: '^1.0.0',
531cb0ef41Sopenharmony_ci        },
541cb0ef41Sopenharmony_ci      }),
551cb0ef41Sopenharmony_ci    },
561cb0ef41Sopenharmony_ci    'prod-dep': {
571cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
581cb0ef41Sopenharmony_ci        name: 'prod-dep',
591cb0ef41Sopenharmony_ci        description: 'A PROD dep kind of dep',
601cb0ef41Sopenharmony_ci        version: '1.0.0',
611cb0ef41Sopenharmony_ci        dependencies: {
621cb0ef41Sopenharmony_ci          dog: '^2.0.0',
631cb0ef41Sopenharmony_ci        },
641cb0ef41Sopenharmony_ci      }),
651cb0ef41Sopenharmony_ci      node_modules: {
661cb0ef41Sopenharmony_ci        dog: {
671cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
681cb0ef41Sopenharmony_ci            name: 'dog',
691cb0ef41Sopenharmony_ci            description: 'A dep that bars',
701cb0ef41Sopenharmony_ci            version: '2.0.0',
711cb0ef41Sopenharmony_ci          }),
721cb0ef41Sopenharmony_ci        },
731cb0ef41Sopenharmony_ci      },
741cb0ef41Sopenharmony_ci    },
751cb0ef41Sopenharmony_ci    'optional-dep': {
761cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
771cb0ef41Sopenharmony_ci        name: 'optional-dep',
781cb0ef41Sopenharmony_ci        description: 'Maybe a dep?',
791cb0ef41Sopenharmony_ci        version: '1.0.0',
801cb0ef41Sopenharmony_ci      }),
811cb0ef41Sopenharmony_ci    },
821cb0ef41Sopenharmony_ci    'peer-dep': {
831cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
841cb0ef41Sopenharmony_ci        name: 'peer-dep',
851cb0ef41Sopenharmony_ci        description: 'Peer-dep description here',
861cb0ef41Sopenharmony_ci        version: '1.0.0',
871cb0ef41Sopenharmony_ci      }),
881cb0ef41Sopenharmony_ci    },
891cb0ef41Sopenharmony_ci    ...simpleNmFixture.node_modules,
901cb0ef41Sopenharmony_ci  },
911cb0ef41Sopenharmony_ci}
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ciconst mockLs = async (t, { mocks, config, ...opts } = {}) => {
941cb0ef41Sopenharmony_ci  const mock = await mockNpm(t, {
951cb0ef41Sopenharmony_ci    ...opts,
961cb0ef41Sopenharmony_ci    config: {
971cb0ef41Sopenharmony_ci      all: true,
981cb0ef41Sopenharmony_ci      ...config,
991cb0ef41Sopenharmony_ci    },
1001cb0ef41Sopenharmony_ci    command: 'ls',
1011cb0ef41Sopenharmony_ci    mocks: {
1021cb0ef41Sopenharmony_ci      path: {
1031cb0ef41Sopenharmony_ci        ...require('path'),
1041cb0ef41Sopenharmony_ci        sep: '/',
1051cb0ef41Sopenharmony_ci      },
1061cb0ef41Sopenharmony_ci      ...mocks,
1071cb0ef41Sopenharmony_ci    },
1081cb0ef41Sopenharmony_ci  })
1091cb0ef41Sopenharmony_ci
1101cb0ef41Sopenharmony_ci  return {
1111cb0ef41Sopenharmony_ci    ...mock,
1121cb0ef41Sopenharmony_ci    result: () => mock.joinedOutput(),
1131cb0ef41Sopenharmony_ci  }
1141cb0ef41Sopenharmony_ci}
1151cb0ef41Sopenharmony_ci
1161cb0ef41Sopenharmony_ciconst redactCwdObj = obj => {
1171cb0ef41Sopenharmony_ci  if (Array.isArray(obj)) {
1181cb0ef41Sopenharmony_ci    return obj.map(o => redactCwdObj(o))
1191cb0ef41Sopenharmony_ci  }
1201cb0ef41Sopenharmony_ci  if (obj && typeof obj === 'object') {
1211cb0ef41Sopenharmony_ci    return Object.keys(obj).reduce((o, k) => {
1221cb0ef41Sopenharmony_ci      o[k] = redactCwdObj(obj[k])
1231cb0ef41Sopenharmony_ci      return o
1241cb0ef41Sopenharmony_ci    }, {})
1251cb0ef41Sopenharmony_ci  }
1261cb0ef41Sopenharmony_ci  return typeof obj === 'string' ? cleanCwd(obj) : obj
1271cb0ef41Sopenharmony_ci}
1281cb0ef41Sopenharmony_ci
1291cb0ef41Sopenharmony_ciconst jsonParse = res => redactCwdObj(JSON.parse(res))
1301cb0ef41Sopenharmony_ci
1311cb0ef41Sopenharmony_cit.test('ls', async t => {
1321cb0ef41Sopenharmony_ci  t.test('no args', async t => {
1331cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
1341cb0ef41Sopenharmony_ci      // config: {},
1351cb0ef41Sopenharmony_ci      prefixDir: {
1361cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1371cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
1381cb0ef41Sopenharmony_ci          version: '1.0.0',
1391cb0ef41Sopenharmony_ci          dependencies: {
1401cb0ef41Sopenharmony_ci            foo: '^1.0.0',
1411cb0ef41Sopenharmony_ci            chai: '^1.0.0',
1421cb0ef41Sopenharmony_ci          },
1431cb0ef41Sopenharmony_ci        }),
1441cb0ef41Sopenharmony_ci        ...simpleNmFixture,
1451cb0ef41Sopenharmony_ci      },
1461cb0ef41Sopenharmony_ci    })
1471cb0ef41Sopenharmony_ci    await ls.exec([])
1481cb0ef41Sopenharmony_ci    t.matchSnapshot(
1491cb0ef41Sopenharmony_ci      cleanCwd(result()),
1501cb0ef41Sopenharmony_ci      'should output tree representation of dependencies structure'
1511cb0ef41Sopenharmony_ci    )
1521cb0ef41Sopenharmony_ci  })
1531cb0ef41Sopenharmony_ci
1541cb0ef41Sopenharmony_ci  t.test('missing package.json', async t => {
1551cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
1561cb0ef41Sopenharmony_ci      config: {},
1571cb0ef41Sopenharmony_ci      prefixDir: {
1581cb0ef41Sopenharmony_ci        ...simpleNmFixture,
1591cb0ef41Sopenharmony_ci      },
1601cb0ef41Sopenharmony_ci    })
1611cb0ef41Sopenharmony_ci    await ls.exec([])
1621cb0ef41Sopenharmony_ci    t.matchSnapshot(
1631cb0ef41Sopenharmony_ci      cleanCwd(result()),
1641cb0ef41Sopenharmony_ci      'should output tree missing name/version of top-level package'
1651cb0ef41Sopenharmony_ci    )
1661cb0ef41Sopenharmony_ci  })
1671cb0ef41Sopenharmony_ci
1681cb0ef41Sopenharmony_ci  t.test('workspace and missing optional dep', async t => {
1691cb0ef41Sopenharmony_ci    const config = {
1701cb0ef41Sopenharmony_ci      'include-workspace-root': true,
1711cb0ef41Sopenharmony_ci      workspace: 'baz',
1721cb0ef41Sopenharmony_ci    }
1731cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
1741cb0ef41Sopenharmony_ci      config,
1751cb0ef41Sopenharmony_ci      prefixDir: {
1761cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1771cb0ef41Sopenharmony_ci          name: 'root',
1781cb0ef41Sopenharmony_ci          dependencies: {
1791cb0ef41Sopenharmony_ci            foo: '^1.0.0',
1801cb0ef41Sopenharmony_ci          },
1811cb0ef41Sopenharmony_ci          optionalDependencies: {
1821cb0ef41Sopenharmony_ci            bar: '^1.0.0',
1831cb0ef41Sopenharmony_ci          },
1841cb0ef41Sopenharmony_ci          workspaces: ['./baz'],
1851cb0ef41Sopenharmony_ci        }),
1861cb0ef41Sopenharmony_ci        baz: {
1871cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
1881cb0ef41Sopenharmony_ci            name: 'baz',
1891cb0ef41Sopenharmony_ci            version: '1.0.0',
1901cb0ef41Sopenharmony_ci          }),
1911cb0ef41Sopenharmony_ci        },
1921cb0ef41Sopenharmony_ci        node_modules: {
1931cb0ef41Sopenharmony_ci          baz: t.fixture('symlink', '../baz'),
1941cb0ef41Sopenharmony_ci          foo: {
1951cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
1961cb0ef41Sopenharmony_ci              name: 'foo',
1971cb0ef41Sopenharmony_ci              version: '1.0.0',
1981cb0ef41Sopenharmony_ci            }),
1991cb0ef41Sopenharmony_ci          },
2001cb0ef41Sopenharmony_ci        },
2011cb0ef41Sopenharmony_ci      },
2021cb0ef41Sopenharmony_ci    })
2031cb0ef41Sopenharmony_ci
2041cb0ef41Sopenharmony_ci    await ls.exec([])
2051cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should omit missing optional dep')
2061cb0ef41Sopenharmony_ci  })
2071cb0ef41Sopenharmony_ci
2081cb0ef41Sopenharmony_ci  t.test('extraneous deps', async t => {
2091cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
2101cb0ef41Sopenharmony_ci      config: {},
2111cb0ef41Sopenharmony_ci      prefixDir: {
2121cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
2131cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
2141cb0ef41Sopenharmony_ci          version: '1.0.0',
2151cb0ef41Sopenharmony_ci          dependencies: {
2161cb0ef41Sopenharmony_ci            foo: '^1.0.0',
2171cb0ef41Sopenharmony_ci          },
2181cb0ef41Sopenharmony_ci        }),
2191cb0ef41Sopenharmony_ci        ...simpleNmFixture,
2201cb0ef41Sopenharmony_ci      },
2211cb0ef41Sopenharmony_ci    })
2221cb0ef41Sopenharmony_ci    await ls.exec([])
2231cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output containing problems info')
2241cb0ef41Sopenharmony_ci  })
2251cb0ef41Sopenharmony_ci
2261cb0ef41Sopenharmony_ci  t.test('overridden dep', async t => {
2271cb0ef41Sopenharmony_ci    const config = {
2281cb0ef41Sopenharmony_ci    }
2291cb0ef41Sopenharmony_ci
2301cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
2311cb0ef41Sopenharmony_ci      config,
2321cb0ef41Sopenharmony_ci      prefixDir: {
2331cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
2341cb0ef41Sopenharmony_ci          name: 'test-overridden',
2351cb0ef41Sopenharmony_ci          version: '1.0.0',
2361cb0ef41Sopenharmony_ci          dependencies: {
2371cb0ef41Sopenharmony_ci            foo: '^1.0.0',
2381cb0ef41Sopenharmony_ci          },
2391cb0ef41Sopenharmony_ci          overrides: {
2401cb0ef41Sopenharmony_ci            bar: '1.0.0',
2411cb0ef41Sopenharmony_ci          },
2421cb0ef41Sopenharmony_ci        }),
2431cb0ef41Sopenharmony_ci        node_modules: {
2441cb0ef41Sopenharmony_ci          foo: {
2451cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
2461cb0ef41Sopenharmony_ci              name: 'foo',
2471cb0ef41Sopenharmony_ci              version: '1.0.0',
2481cb0ef41Sopenharmony_ci              dependencies: {
2491cb0ef41Sopenharmony_ci                bar: '^2.0.0',
2501cb0ef41Sopenharmony_ci              },
2511cb0ef41Sopenharmony_ci            }),
2521cb0ef41Sopenharmony_ci          },
2531cb0ef41Sopenharmony_ci          bar: {
2541cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
2551cb0ef41Sopenharmony_ci              name: 'bar',
2561cb0ef41Sopenharmony_ci              version: '1.0.0',
2571cb0ef41Sopenharmony_ci            }),
2581cb0ef41Sopenharmony_ci          },
2591cb0ef41Sopenharmony_ci        },
2601cb0ef41Sopenharmony_ci      },
2611cb0ef41Sopenharmony_ci    })
2621cb0ef41Sopenharmony_ci
2631cb0ef41Sopenharmony_ci    await
2641cb0ef41Sopenharmony_ci
2651cb0ef41Sopenharmony_ci    ls.exec([])
2661cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should contain overridden outout')
2671cb0ef41Sopenharmony_ci  })
2681cb0ef41Sopenharmony_ci
2691cb0ef41Sopenharmony_ci  t.test('overridden dep w/ color', async t => {
2701cb0ef41Sopenharmony_ci    const config = {
2711cb0ef41Sopenharmony_ci      color: 'always',
2721cb0ef41Sopenharmony_ci    }
2731cb0ef41Sopenharmony_ci
2741cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
2751cb0ef41Sopenharmony_ci      config,
2761cb0ef41Sopenharmony_ci      prefixDir: {
2771cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
2781cb0ef41Sopenharmony_ci          name: 'test-overridden',
2791cb0ef41Sopenharmony_ci          version: '1.0.0',
2801cb0ef41Sopenharmony_ci          dependencies: {
2811cb0ef41Sopenharmony_ci            foo: '^1.0.0',
2821cb0ef41Sopenharmony_ci          },
2831cb0ef41Sopenharmony_ci          overrides: {
2841cb0ef41Sopenharmony_ci            bar: '1.0.0',
2851cb0ef41Sopenharmony_ci          },
2861cb0ef41Sopenharmony_ci        }),
2871cb0ef41Sopenharmony_ci        node_modules: {
2881cb0ef41Sopenharmony_ci          foo: {
2891cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
2901cb0ef41Sopenharmony_ci              name: 'foo',
2911cb0ef41Sopenharmony_ci              version: '1.0.0',
2921cb0ef41Sopenharmony_ci              dependencies: {
2931cb0ef41Sopenharmony_ci                bar: '^2.0.0',
2941cb0ef41Sopenharmony_ci              },
2951cb0ef41Sopenharmony_ci            }),
2961cb0ef41Sopenharmony_ci          },
2971cb0ef41Sopenharmony_ci          bar: {
2981cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
2991cb0ef41Sopenharmony_ci              name: 'bar',
3001cb0ef41Sopenharmony_ci              version: '1.0.0',
3011cb0ef41Sopenharmony_ci            }),
3021cb0ef41Sopenharmony_ci          },
3031cb0ef41Sopenharmony_ci        },
3041cb0ef41Sopenharmony_ci      },
3051cb0ef41Sopenharmony_ci    })
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ci    await ls.exec([])
3081cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should contain overridden outout')
3091cb0ef41Sopenharmony_ci  })
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci  t.test('with filter arg', async t => {
3121cb0ef41Sopenharmony_ci    const config = {
3131cb0ef41Sopenharmony_ci      color: 'always',
3141cb0ef41Sopenharmony_ci    }
3151cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
3161cb0ef41Sopenharmony_ci      config,
3171cb0ef41Sopenharmony_ci      prefixDir: {
3181cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
3191cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
3201cb0ef41Sopenharmony_ci          version: '1.0.0',
3211cb0ef41Sopenharmony_ci          dependencies: {
3221cb0ef41Sopenharmony_ci            foo: '^1.0.0',
3231cb0ef41Sopenharmony_ci            chai: '^1.0.0',
3241cb0ef41Sopenharmony_ci          },
3251cb0ef41Sopenharmony_ci        }),
3261cb0ef41Sopenharmony_ci        ...simpleNmFixture,
3271cb0ef41Sopenharmony_ci      },
3281cb0ef41Sopenharmony_ci    })
3291cb0ef41Sopenharmony_ci    await ls.exec(['chai'])
3301cb0ef41Sopenharmony_ci    t.matchSnapshot(
3311cb0ef41Sopenharmony_ci      cleanCwd(result()),
3321cb0ef41Sopenharmony_ci      'should output tree contaning only occurrences of filtered by package and colored output'
3331cb0ef41Sopenharmony_ci    )
3341cb0ef41Sopenharmony_ci  })
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci  t.test('with dot filter arg', async t => {
3371cb0ef41Sopenharmony_ci    const config = {
3381cb0ef41Sopenharmony_ci      all: false,
3391cb0ef41Sopenharmony_ci      depth: 0,
3401cb0ef41Sopenharmony_ci    }
3411cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
3421cb0ef41Sopenharmony_ci      config,
3431cb0ef41Sopenharmony_ci      prefixDir: {
3441cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
3451cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
3461cb0ef41Sopenharmony_ci          version: '1.0.0',
3471cb0ef41Sopenharmony_ci          dependencies: {
3481cb0ef41Sopenharmony_ci            foo: '^1.0.0',
3491cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
3501cb0ef41Sopenharmony_ci          },
3511cb0ef41Sopenharmony_ci        }),
3521cb0ef41Sopenharmony_ci        ...simpleNmFixture,
3531cb0ef41Sopenharmony_ci      },
3541cb0ef41Sopenharmony_ci    })
3551cb0ef41Sopenharmony_ci    await ls.exec(['.'])
3561cb0ef41Sopenharmony_ci    t.matchSnapshot(
3571cb0ef41Sopenharmony_ci      cleanCwd(result()),
3581cb0ef41Sopenharmony_ci      'should output tree contaning only occurrences of filtered by package and colored output'
3591cb0ef41Sopenharmony_ci    )
3601cb0ef41Sopenharmony_ci  })
3611cb0ef41Sopenharmony_ci
3621cb0ef41Sopenharmony_ci  t.test('with filter arg nested dep', async t => {
3631cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
3641cb0ef41Sopenharmony_ci      config: {},
3651cb0ef41Sopenharmony_ci      prefixDir: {
3661cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
3671cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
3681cb0ef41Sopenharmony_ci          version: '1.0.0',
3691cb0ef41Sopenharmony_ci          dependencies: {
3701cb0ef41Sopenharmony_ci            foo: '^1.0.0',
3711cb0ef41Sopenharmony_ci            chai: '^1.0.0',
3721cb0ef41Sopenharmony_ci          },
3731cb0ef41Sopenharmony_ci        }),
3741cb0ef41Sopenharmony_ci        ...simpleNmFixture,
3751cb0ef41Sopenharmony_ci      },
3761cb0ef41Sopenharmony_ci    })
3771cb0ef41Sopenharmony_ci    await ls.exec(['dog'])
3781cb0ef41Sopenharmony_ci    t.matchSnapshot(
3791cb0ef41Sopenharmony_ci      cleanCwd(result()),
3801cb0ef41Sopenharmony_ci      'should output tree contaning only occurrences of filtered package and its ancestors'
3811cb0ef41Sopenharmony_ci    )
3821cb0ef41Sopenharmony_ci  })
3831cb0ef41Sopenharmony_ci
3841cb0ef41Sopenharmony_ci  t.test('with multiple filter args', async t => {
3851cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
3861cb0ef41Sopenharmony_ci      config: {},
3871cb0ef41Sopenharmony_ci      prefixDir: {
3881cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
3891cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
3901cb0ef41Sopenharmony_ci          version: '1.0.0',
3911cb0ef41Sopenharmony_ci          dependencies: {
3921cb0ef41Sopenharmony_ci            foo: '^1.0.0',
3931cb0ef41Sopenharmony_ci            chai: '^1.0.0',
3941cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
3951cb0ef41Sopenharmony_ci          },
3961cb0ef41Sopenharmony_ci        }),
3971cb0ef41Sopenharmony_ci        node_modules: {
3981cb0ef41Sopenharmony_ci          ...simpleNmFixture.node_modules,
3991cb0ef41Sopenharmony_ci          ipsum: {
4001cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
4011cb0ef41Sopenharmony_ci              name: 'ipsum',
4021cb0ef41Sopenharmony_ci              version: '1.0.0',
4031cb0ef41Sopenharmony_ci            }),
4041cb0ef41Sopenharmony_ci          },
4051cb0ef41Sopenharmony_ci        },
4061cb0ef41Sopenharmony_ci      },
4071cb0ef41Sopenharmony_ci    })
4081cb0ef41Sopenharmony_ci    await ls.exec(['dog@*', 'chai@1.0.0'])
4091cb0ef41Sopenharmony_ci    t.matchSnapshot(
4101cb0ef41Sopenharmony_ci      cleanCwd(result()),
4111cb0ef41Sopenharmony_ci      /* eslint-disable-next-line max-len */
4121cb0ef41Sopenharmony_ci      'should output tree contaning only occurrences of multiple filtered packages and their ancestors'
4131cb0ef41Sopenharmony_ci    )
4141cb0ef41Sopenharmony_ci  })
4151cb0ef41Sopenharmony_ci
4161cb0ef41Sopenharmony_ci  t.test('with missing filter arg', async t => {
4171cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
4181cb0ef41Sopenharmony_ci      config: {},
4191cb0ef41Sopenharmony_ci      prefixDir: {
4201cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
4211cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
4221cb0ef41Sopenharmony_ci          version: '1.0.0',
4231cb0ef41Sopenharmony_ci          dependencies: {
4241cb0ef41Sopenharmony_ci            foo: '^1.0.0',
4251cb0ef41Sopenharmony_ci            chai: '^1.0.0',
4261cb0ef41Sopenharmony_ci          },
4271cb0ef41Sopenharmony_ci        }),
4281cb0ef41Sopenharmony_ci        ...simpleNmFixture,
4291cb0ef41Sopenharmony_ci      },
4301cb0ef41Sopenharmony_ci    })
4311cb0ef41Sopenharmony_ci    await ls.exec(['notadep'])
4321cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing no dependencies info')
4331cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1, 'should exit with error code 1')
4341cb0ef41Sopenharmony_ci  })
4351cb0ef41Sopenharmony_ci
4361cb0ef41Sopenharmony_ci  t.test('default --depth value should be 0', async t => {
4371cb0ef41Sopenharmony_ci    const config = {
4381cb0ef41Sopenharmony_ci      all: false,
4391cb0ef41Sopenharmony_ci    }
4401cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
4411cb0ef41Sopenharmony_ci      config,
4421cb0ef41Sopenharmony_ci      prefixDir: {
4431cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
4441cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
4451cb0ef41Sopenharmony_ci          version: '1.0.0',
4461cb0ef41Sopenharmony_ci          dependencies: {
4471cb0ef41Sopenharmony_ci            foo: '^1.0.0',
4481cb0ef41Sopenharmony_ci            chai: '^1.0.0',
4491cb0ef41Sopenharmony_ci          },
4501cb0ef41Sopenharmony_ci        }),
4511cb0ef41Sopenharmony_ci        ...simpleNmFixture,
4521cb0ef41Sopenharmony_ci      },
4531cb0ef41Sopenharmony_ci    })
4541cb0ef41Sopenharmony_ci    await ls.exec([])
4551cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()),
4561cb0ef41Sopenharmony_ci      'should output tree containing only top-level dependencies')
4571cb0ef41Sopenharmony_ci  })
4581cb0ef41Sopenharmony_ci
4591cb0ef41Sopenharmony_ci  t.test('--depth=0', async t => {
4601cb0ef41Sopenharmony_ci    const config = {
4611cb0ef41Sopenharmony_ci      all: false,
4621cb0ef41Sopenharmony_ci      depth: 0,
4631cb0ef41Sopenharmony_ci    }
4641cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
4651cb0ef41Sopenharmony_ci      config,
4661cb0ef41Sopenharmony_ci      prefixDir: {
4671cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
4681cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
4691cb0ef41Sopenharmony_ci          version: '1.0.0',
4701cb0ef41Sopenharmony_ci          dependencies: {
4711cb0ef41Sopenharmony_ci            foo: '^1.0.0',
4721cb0ef41Sopenharmony_ci            chai: '^1.0.0',
4731cb0ef41Sopenharmony_ci          },
4741cb0ef41Sopenharmony_ci        }),
4751cb0ef41Sopenharmony_ci        ...simpleNmFixture,
4761cb0ef41Sopenharmony_ci      },
4771cb0ef41Sopenharmony_ci    })
4781cb0ef41Sopenharmony_ci    await ls.exec([])
4791cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()),
4801cb0ef41Sopenharmony_ci      'should output tree containing only top-level dependencies')
4811cb0ef41Sopenharmony_ci  })
4821cb0ef41Sopenharmony_ci
4831cb0ef41Sopenharmony_ci  t.test('--depth=1', async t => {
4841cb0ef41Sopenharmony_ci    const config = {
4851cb0ef41Sopenharmony_ci      all: false,
4861cb0ef41Sopenharmony_ci      depth: 1,
4871cb0ef41Sopenharmony_ci    }
4881cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
4891cb0ef41Sopenharmony_ci      config,
4901cb0ef41Sopenharmony_ci      prefixDir: {
4911cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
4921cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
4931cb0ef41Sopenharmony_ci          version: '1.0.0',
4941cb0ef41Sopenharmony_ci          dependencies: {
4951cb0ef41Sopenharmony_ci            a: '^1.0.0',
4961cb0ef41Sopenharmony_ci            e: '^1.0.0',
4971cb0ef41Sopenharmony_ci          },
4981cb0ef41Sopenharmony_ci        }),
4991cb0ef41Sopenharmony_ci        node_modules: {
5001cb0ef41Sopenharmony_ci          a: {
5011cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
5021cb0ef41Sopenharmony_ci              name: 'a',
5031cb0ef41Sopenharmony_ci              version: '1.0.0',
5041cb0ef41Sopenharmony_ci              dependencies: {
5051cb0ef41Sopenharmony_ci                b: '^1.0.0',
5061cb0ef41Sopenharmony_ci              },
5071cb0ef41Sopenharmony_ci            }),
5081cb0ef41Sopenharmony_ci          },
5091cb0ef41Sopenharmony_ci          b: {
5101cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
5111cb0ef41Sopenharmony_ci              name: 'b',
5121cb0ef41Sopenharmony_ci              version: '1.0.0',
5131cb0ef41Sopenharmony_ci              dependencies: {
5141cb0ef41Sopenharmony_ci                c: '^1.0.0',
5151cb0ef41Sopenharmony_ci                d: '*',
5161cb0ef41Sopenharmony_ci              },
5171cb0ef41Sopenharmony_ci            }),
5181cb0ef41Sopenharmony_ci          },
5191cb0ef41Sopenharmony_ci          c: {
5201cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
5211cb0ef41Sopenharmony_ci              name: 'c',
5221cb0ef41Sopenharmony_ci              version: '1.0.0',
5231cb0ef41Sopenharmony_ci            }),
5241cb0ef41Sopenharmony_ci          },
5251cb0ef41Sopenharmony_ci          d: {
5261cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
5271cb0ef41Sopenharmony_ci              name: 'd',
5281cb0ef41Sopenharmony_ci              version: '1.0.0',
5291cb0ef41Sopenharmony_ci            }),
5301cb0ef41Sopenharmony_ci          },
5311cb0ef41Sopenharmony_ci          e: {
5321cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
5331cb0ef41Sopenharmony_ci              name: 'e',
5341cb0ef41Sopenharmony_ci              version: '1.0.0',
5351cb0ef41Sopenharmony_ci            }),
5361cb0ef41Sopenharmony_ci          },
5371cb0ef41Sopenharmony_ci        },
5381cb0ef41Sopenharmony_ci      },
5391cb0ef41Sopenharmony_ci    })
5401cb0ef41Sopenharmony_ci    await ls.exec([])
5411cb0ef41Sopenharmony_ci    t.matchSnapshot(
5421cb0ef41Sopenharmony_ci      cleanCwd(result()),
5431cb0ef41Sopenharmony_ci      'should output tree containing top-level deps and their deps only'
5441cb0ef41Sopenharmony_ci    )
5451cb0ef41Sopenharmony_ci  })
5461cb0ef41Sopenharmony_ci
5471cb0ef41Sopenharmony_ci  t.test('missing/invalid/extraneous', async t => {
5481cb0ef41Sopenharmony_ci    t.plan(3)
5491cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
5501cb0ef41Sopenharmony_ci      config: {},
5511cb0ef41Sopenharmony_ci      prefixDir: {
5521cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
5531cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
5541cb0ef41Sopenharmony_ci          version: '1.0.0',
5551cb0ef41Sopenharmony_ci          dependencies: {
5561cb0ef41Sopenharmony_ci            foo: '^2.0.0',
5571cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
5581cb0ef41Sopenharmony_ci          },
5591cb0ef41Sopenharmony_ci        }),
5601cb0ef41Sopenharmony_ci        ...simpleNmFixture,
5611cb0ef41Sopenharmony_ci      },
5621cb0ef41Sopenharmony_ci    })
5631cb0ef41Sopenharmony_ci    await ls.exec([]).catch(err => {
5641cb0ef41Sopenharmony_ci      t.equal(err.code, 'ELSPROBLEMS', 'should have error code')
5651cb0ef41Sopenharmony_ci      t.equal(
5661cb0ef41Sopenharmony_ci        cleanCwd(err.message),
5671cb0ef41Sopenharmony_ci        'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai\n' +
5681cb0ef41Sopenharmony_ci        'invalid: foo@1.0.0 {CWD}/prefix/node_modules/foo\n' +
5691cb0ef41Sopenharmony_ci        'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0',
5701cb0ef41Sopenharmony_ci        'should log missing/invalid/extraneous errors'
5711cb0ef41Sopenharmony_ci      )
5721cb0ef41Sopenharmony_ci    })
5731cb0ef41Sopenharmony_ci    t.matchSnapshot(
5741cb0ef41Sopenharmony_ci      cleanCwd(result()),
5751cb0ef41Sopenharmony_ci      'should output tree containing missing, invalid, extraneous labels'
5761cb0ef41Sopenharmony_ci    )
5771cb0ef41Sopenharmony_ci  })
5781cb0ef41Sopenharmony_ci
5791cb0ef41Sopenharmony_ci  t.test('colored output', async t => {
5801cb0ef41Sopenharmony_ci    const config = {
5811cb0ef41Sopenharmony_ci      color: 'always',
5821cb0ef41Sopenharmony_ci    }
5831cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
5841cb0ef41Sopenharmony_ci      config,
5851cb0ef41Sopenharmony_ci      prefixDir: {
5861cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
5871cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
5881cb0ef41Sopenharmony_ci          version: '1.0.0',
5891cb0ef41Sopenharmony_ci          dependencies: {
5901cb0ef41Sopenharmony_ci            foo: '^2.0.0',
5911cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
5921cb0ef41Sopenharmony_ci          },
5931cb0ef41Sopenharmony_ci        }),
5941cb0ef41Sopenharmony_ci        ...simpleNmFixture,
5951cb0ef41Sopenharmony_ci      },
5961cb0ef41Sopenharmony_ci    })
5971cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' }, 'should have error code')
5981cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing color info')
5991cb0ef41Sopenharmony_ci  })
6001cb0ef41Sopenharmony_ci
6011cb0ef41Sopenharmony_ci  t.test('--dev', async t => {
6021cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
6031cb0ef41Sopenharmony_ci      config: {
6041cb0ef41Sopenharmony_ci        omit: ['peer', 'prod', 'optional'],
6051cb0ef41Sopenharmony_ci      },
6061cb0ef41Sopenharmony_ci      prefixDir: {
6071cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
6081cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
6091cb0ef41Sopenharmony_ci          version: '1.0.0',
6101cb0ef41Sopenharmony_ci          dependencies: {
6111cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
6121cb0ef41Sopenharmony_ci            chai: '^1.0.0',
6131cb0ef41Sopenharmony_ci          },
6141cb0ef41Sopenharmony_ci          devDependencies: {
6151cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
6161cb0ef41Sopenharmony_ci          },
6171cb0ef41Sopenharmony_ci          optionalDependencies: {
6181cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
6191cb0ef41Sopenharmony_ci          },
6201cb0ef41Sopenharmony_ci          peerDependencies: {
6211cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
6221cb0ef41Sopenharmony_ci          },
6231cb0ef41Sopenharmony_ci        }),
6241cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
6251cb0ef41Sopenharmony_ci      },
6261cb0ef41Sopenharmony_ci    })
6271cb0ef41Sopenharmony_ci    await ls.exec([])
6281cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing dev deps')
6291cb0ef41Sopenharmony_ci  })
6301cb0ef41Sopenharmony_ci
6311cb0ef41Sopenharmony_ci  t.test('--link', async t => {
6321cb0ef41Sopenharmony_ci    const config = {
6331cb0ef41Sopenharmony_ci      link: true,
6341cb0ef41Sopenharmony_ci    }
6351cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
6361cb0ef41Sopenharmony_ci      config,
6371cb0ef41Sopenharmony_ci      prefixDir: {
6381cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
6391cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
6401cb0ef41Sopenharmony_ci          version: '1.0.0',
6411cb0ef41Sopenharmony_ci          dependencies: {
6421cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
6431cb0ef41Sopenharmony_ci            chai: '^1.0.0',
6441cb0ef41Sopenharmony_ci            'linked-dep': '^1.0.0',
6451cb0ef41Sopenharmony_ci          },
6461cb0ef41Sopenharmony_ci          devDependencies: {
6471cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
6481cb0ef41Sopenharmony_ci          },
6491cb0ef41Sopenharmony_ci          optionalDependencies: {
6501cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
6511cb0ef41Sopenharmony_ci          },
6521cb0ef41Sopenharmony_ci          peerDependencies: {
6531cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
6541cb0ef41Sopenharmony_ci          },
6551cb0ef41Sopenharmony_ci        }),
6561cb0ef41Sopenharmony_ci        'linked-dep': {
6571cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
6581cb0ef41Sopenharmony_ci            name: 'linked-dep',
6591cb0ef41Sopenharmony_ci            version: '1.0.0',
6601cb0ef41Sopenharmony_ci          }),
6611cb0ef41Sopenharmony_ci        },
6621cb0ef41Sopenharmony_ci        node_modules: {
6631cb0ef41Sopenharmony_ci          'linked-dep': t.fixture('symlink', '../linked-dep'),
6641cb0ef41Sopenharmony_ci          ...diffDepTypesNmFixture.node_modules,
6651cb0ef41Sopenharmony_ci        },
6661cb0ef41Sopenharmony_ci      },
6671cb0ef41Sopenharmony_ci    })
6681cb0ef41Sopenharmony_ci    await ls.exec([])
6691cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing linked deps')
6701cb0ef41Sopenharmony_ci  })
6711cb0ef41Sopenharmony_ci
6721cb0ef41Sopenharmony_ci  t.test('print deduped symlinks', async t => {
6731cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
6741cb0ef41Sopenharmony_ci      config: {},
6751cb0ef41Sopenharmony_ci      prefixDir: {
6761cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
6771cb0ef41Sopenharmony_ci          name: 'print-deduped-symlinks',
6781cb0ef41Sopenharmony_ci          version: '1.0.0',
6791cb0ef41Sopenharmony_ci          dependencies: {
6801cb0ef41Sopenharmony_ci            a: '^1.0.0',
6811cb0ef41Sopenharmony_ci            b: '^1.0.0',
6821cb0ef41Sopenharmony_ci          },
6831cb0ef41Sopenharmony_ci        }),
6841cb0ef41Sopenharmony_ci        b: {
6851cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
6861cb0ef41Sopenharmony_ci            name: 'b',
6871cb0ef41Sopenharmony_ci            version: '1.0.0',
6881cb0ef41Sopenharmony_ci          }),
6891cb0ef41Sopenharmony_ci        },
6901cb0ef41Sopenharmony_ci        node_modules: {
6911cb0ef41Sopenharmony_ci          a: {
6921cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
6931cb0ef41Sopenharmony_ci              name: 'a',
6941cb0ef41Sopenharmony_ci              version: '1.0.0',
6951cb0ef41Sopenharmony_ci              dependencies: {
6961cb0ef41Sopenharmony_ci                b: '^1.0.0',
6971cb0ef41Sopenharmony_ci              },
6981cb0ef41Sopenharmony_ci            }),
6991cb0ef41Sopenharmony_ci          },
7001cb0ef41Sopenharmony_ci          b: t.fixture('symlink', '../b'),
7011cb0ef41Sopenharmony_ci        },
7021cb0ef41Sopenharmony_ci      },
7031cb0ef41Sopenharmony_ci    })
7041cb0ef41Sopenharmony_ci    await ls.exec([])
7051cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing linked deps')
7061cb0ef41Sopenharmony_ci  })
7071cb0ef41Sopenharmony_ci
7081cb0ef41Sopenharmony_ci  t.test('--production', async t => {
7091cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
7101cb0ef41Sopenharmony_ci      config: { omit: ['dev', 'peer'] },
7111cb0ef41Sopenharmony_ci      prefixDir: {
7121cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
7131cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
7141cb0ef41Sopenharmony_ci          version: '1.0.0',
7151cb0ef41Sopenharmony_ci          dependencies: {
7161cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
7171cb0ef41Sopenharmony_ci            chai: '^1.0.0',
7181cb0ef41Sopenharmony_ci          },
7191cb0ef41Sopenharmony_ci          devDependencies: {
7201cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
7211cb0ef41Sopenharmony_ci          },
7221cb0ef41Sopenharmony_ci          optionalDependencies: {
7231cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
7241cb0ef41Sopenharmony_ci          },
7251cb0ef41Sopenharmony_ci          peerDependencies: {
7261cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
7271cb0ef41Sopenharmony_ci          },
7281cb0ef41Sopenharmony_ci        }),
7291cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
7301cb0ef41Sopenharmony_ci      },
7311cb0ef41Sopenharmony_ci    })
7321cb0ef41Sopenharmony_ci    await ls.exec([])
7331cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing production deps')
7341cb0ef41Sopenharmony_ci  })
7351cb0ef41Sopenharmony_ci
7361cb0ef41Sopenharmony_ci  t.test('--long', async t => {
7371cb0ef41Sopenharmony_ci    const config = {
7381cb0ef41Sopenharmony_ci      long: true,
7391cb0ef41Sopenharmony_ci    }
7401cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
7411cb0ef41Sopenharmony_ci      config,
7421cb0ef41Sopenharmony_ci      prefixDir: {
7431cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
7441cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
7451cb0ef41Sopenharmony_ci          version: '1.0.0',
7461cb0ef41Sopenharmony_ci          dependencies: {
7471cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
7481cb0ef41Sopenharmony_ci            chai: '^1.0.0',
7491cb0ef41Sopenharmony_ci          },
7501cb0ef41Sopenharmony_ci          devDependencies: {
7511cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
7521cb0ef41Sopenharmony_ci          },
7531cb0ef41Sopenharmony_ci          optionalDependencies: {
7541cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
7551cb0ef41Sopenharmony_ci          },
7561cb0ef41Sopenharmony_ci          peerDependencies: {
7571cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
7581cb0ef41Sopenharmony_ci          },
7591cb0ef41Sopenharmony_ci        }),
7601cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
7611cb0ef41Sopenharmony_ci      },
7621cb0ef41Sopenharmony_ci    })
7631cb0ef41Sopenharmony_ci    await ls.exec([])
7641cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree info with descriptions')
7651cb0ef41Sopenharmony_ci  })
7661cb0ef41Sopenharmony_ci
7671cb0ef41Sopenharmony_ci  t.test('--long --depth=0', async t => {
7681cb0ef41Sopenharmony_ci    const config = {
7691cb0ef41Sopenharmony_ci      all: false,
7701cb0ef41Sopenharmony_ci      depth: 0,
7711cb0ef41Sopenharmony_ci      long: true,
7721cb0ef41Sopenharmony_ci    }
7731cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
7741cb0ef41Sopenharmony_ci      config,
7751cb0ef41Sopenharmony_ci      prefixDir: {
7761cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
7771cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
7781cb0ef41Sopenharmony_ci          version: '1.0.0',
7791cb0ef41Sopenharmony_ci          dependencies: {
7801cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
7811cb0ef41Sopenharmony_ci            chai: '^1.0.0',
7821cb0ef41Sopenharmony_ci          },
7831cb0ef41Sopenharmony_ci          devDependencies: {
7841cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
7851cb0ef41Sopenharmony_ci          },
7861cb0ef41Sopenharmony_ci          optionalDependencies: {
7871cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
7881cb0ef41Sopenharmony_ci          },
7891cb0ef41Sopenharmony_ci          peerDependencies: {
7901cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
7911cb0ef41Sopenharmony_ci          },
7921cb0ef41Sopenharmony_ci        }),
7931cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
7941cb0ef41Sopenharmony_ci      },
7951cb0ef41Sopenharmony_ci    })
7961cb0ef41Sopenharmony_ci    await ls.exec([])
7971cb0ef41Sopenharmony_ci    t.matchSnapshot(
7981cb0ef41Sopenharmony_ci      cleanCwd(result()),
7991cb0ef41Sopenharmony_ci      'should output tree containing top-level deps with descriptions'
8001cb0ef41Sopenharmony_ci    )
8011cb0ef41Sopenharmony_ci  })
8021cb0ef41Sopenharmony_ci
8031cb0ef41Sopenharmony_ci  t.test('json read problems', async t => {
8041cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
8051cb0ef41Sopenharmony_ci      config: {},
8061cb0ef41Sopenharmony_ci      prefixDir: {
8071cb0ef41Sopenharmony_ci        'package.json': '{broken json',
8081cb0ef41Sopenharmony_ci      },
8091cb0ef41Sopenharmony_ci    })
8101cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'EJSONPARSE' }, 'should throw EJSONPARSE error')
8111cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print empty result')
8121cb0ef41Sopenharmony_ci  })
8131cb0ef41Sopenharmony_ci
8141cb0ef41Sopenharmony_ci  t.test('empty location', async t => {
8151cb0ef41Sopenharmony_ci    const { ls, result } = await mockLs(t)
8161cb0ef41Sopenharmony_ci    await ls.exec([])
8171cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print empty result')
8181cb0ef41Sopenharmony_ci  })
8191cb0ef41Sopenharmony_ci
8201cb0ef41Sopenharmony_ci  t.test('invalid peer dep', async t => {
8211cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
8221cb0ef41Sopenharmony_ci      config: {},
8231cb0ef41Sopenharmony_ci      prefixDir: {
8241cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
8251cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
8261cb0ef41Sopenharmony_ci          version: '1.0.0',
8271cb0ef41Sopenharmony_ci          dependencies: {
8281cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
8291cb0ef41Sopenharmony_ci            chai: '^1.0.0',
8301cb0ef41Sopenharmony_ci          },
8311cb0ef41Sopenharmony_ci          devDependencies: {
8321cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
8331cb0ef41Sopenharmony_ci          },
8341cb0ef41Sopenharmony_ci          optionalDependencies: {
8351cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
8361cb0ef41Sopenharmony_ci          },
8371cb0ef41Sopenharmony_ci          peerDependencies: {
8381cb0ef41Sopenharmony_ci            'peer-dep': '^2.0.0', // mismatching version #
8391cb0ef41Sopenharmony_ci          },
8401cb0ef41Sopenharmony_ci        }),
8411cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
8421cb0ef41Sopenharmony_ci      },
8431cb0ef41Sopenharmony_ci    })
8441cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]))
8451cb0ef41Sopenharmony_ci    t.matchSnapshot(
8461cb0ef41Sopenharmony_ci      cleanCwd(result()),
8471cb0ef41Sopenharmony_ci      'should output tree signaling mismatching peer dep in problems'
8481cb0ef41Sopenharmony_ci    )
8491cb0ef41Sopenharmony_ci  })
8501cb0ef41Sopenharmony_ci
8511cb0ef41Sopenharmony_ci  t.test('invalid deduped dep', async t => {
8521cb0ef41Sopenharmony_ci    const config = {
8531cb0ef41Sopenharmony_ci      color: 'always',
8541cb0ef41Sopenharmony_ci    }
8551cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
8561cb0ef41Sopenharmony_ci      config,
8571cb0ef41Sopenharmony_ci      prefixDir: {
8581cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
8591cb0ef41Sopenharmony_ci          name: 'invalid-deduped-dep',
8601cb0ef41Sopenharmony_ci          version: '1.0.0',
8611cb0ef41Sopenharmony_ci          dependencies: {
8621cb0ef41Sopenharmony_ci            a: '^1.0.0',
8631cb0ef41Sopenharmony_ci            b: '^2.0.0',
8641cb0ef41Sopenharmony_ci          },
8651cb0ef41Sopenharmony_ci        }),
8661cb0ef41Sopenharmony_ci        node_modules: {
8671cb0ef41Sopenharmony_ci          a: {
8681cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
8691cb0ef41Sopenharmony_ci              name: 'a',
8701cb0ef41Sopenharmony_ci              version: '1.0.0',
8711cb0ef41Sopenharmony_ci              dependencies: {
8721cb0ef41Sopenharmony_ci                b: '^2.0.0',
8731cb0ef41Sopenharmony_ci              },
8741cb0ef41Sopenharmony_ci            }),
8751cb0ef41Sopenharmony_ci          },
8761cb0ef41Sopenharmony_ci          b: {
8771cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
8781cb0ef41Sopenharmony_ci              name: 'b',
8791cb0ef41Sopenharmony_ci              version: '1.0.0',
8801cb0ef41Sopenharmony_ci            }),
8811cb0ef41Sopenharmony_ci          },
8821cb0ef41Sopenharmony_ci        },
8831cb0ef41Sopenharmony_ci      },
8841cb0ef41Sopenharmony_ci    })
8851cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]))
8861cb0ef41Sopenharmony_ci    t.matchSnapshot(
8871cb0ef41Sopenharmony_ci      cleanCwd(result()),
8881cb0ef41Sopenharmony_ci      'should output tree signaling mismatching peer dep in problems'
8891cb0ef41Sopenharmony_ci    )
8901cb0ef41Sopenharmony_ci  })
8911cb0ef41Sopenharmony_ci
8921cb0ef41Sopenharmony_ci  t.test('deduped missing dep', async t => {
8931cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
8941cb0ef41Sopenharmony_ci      config: {},
8951cb0ef41Sopenharmony_ci      prefixDir: {
8961cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
8971cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
8981cb0ef41Sopenharmony_ci          version: '1.0.0',
8991cb0ef41Sopenharmony_ci          dependencies: {
9001cb0ef41Sopenharmony_ci            a: '^1.0.0',
9011cb0ef41Sopenharmony_ci            b: '^1.0.0',
9021cb0ef41Sopenharmony_ci          },
9031cb0ef41Sopenharmony_ci        }),
9041cb0ef41Sopenharmony_ci        node_modules: {
9051cb0ef41Sopenharmony_ci          a: {
9061cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
9071cb0ef41Sopenharmony_ci              name: 'a',
9081cb0ef41Sopenharmony_ci              version: '1.0.0',
9091cb0ef41Sopenharmony_ci              dependencies: {
9101cb0ef41Sopenharmony_ci                b: '^1.0.0',
9111cb0ef41Sopenharmony_ci              },
9121cb0ef41Sopenharmony_ci            }),
9131cb0ef41Sopenharmony_ci          },
9141cb0ef41Sopenharmony_ci        },
9151cb0ef41Sopenharmony_ci      },
9161cb0ef41Sopenharmony_ci    })
9171cb0ef41Sopenharmony_ci    await t.rejects(
9181cb0ef41Sopenharmony_ci      ls.exec([]),
9191cb0ef41Sopenharmony_ci      { code: 'ELSPROBLEMS', message: /missing: b@\^1.0.0/ },
9201cb0ef41Sopenharmony_ci      'should list missing dep problem'
9211cb0ef41Sopenharmony_ci    )
9221cb0ef41Sopenharmony_ci    t.matchSnapshot(
9231cb0ef41Sopenharmony_ci      cleanCwd(result()),
9241cb0ef41Sopenharmony_ci      'should output parseable signaling missing peer dep in problems'
9251cb0ef41Sopenharmony_ci    )
9261cb0ef41Sopenharmony_ci  })
9271cb0ef41Sopenharmony_ci
9281cb0ef41Sopenharmony_ci  t.test('unmet peer dep', async t => {
9291cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
9301cb0ef41Sopenharmony_ci      config: {},
9311cb0ef41Sopenharmony_ci      prefixDir: {
9321cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
9331cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
9341cb0ef41Sopenharmony_ci          version: '1.0.0',
9351cb0ef41Sopenharmony_ci          peerDependencies: {
9361cb0ef41Sopenharmony_ci            'peer-dep': '*',
9371cb0ef41Sopenharmony_ci          },
9381cb0ef41Sopenharmony_ci        }),
9391cb0ef41Sopenharmony_ci      },
9401cb0ef41Sopenharmony_ci    })
9411cb0ef41Sopenharmony_ci    await t.rejects(
9421cb0ef41Sopenharmony_ci      ls.exec([]),
9431cb0ef41Sopenharmony_ci      { code: 'ELSPROBLEMS', message: 'missing: peer-dep@*, required by test-npm-ls@1.0.0' },
9441cb0ef41Sopenharmony_ci      'should have missing peer-dep error msg'
9451cb0ef41Sopenharmony_ci    )
9461cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()),
9471cb0ef41Sopenharmony_ci      'should output tree signaling missing peer dep in problems')
9481cb0ef41Sopenharmony_ci  })
9491cb0ef41Sopenharmony_ci
9501cb0ef41Sopenharmony_ci  t.test('unmet optional dep', async t => {
9511cb0ef41Sopenharmony_ci    const config = { color: 'always' }
9521cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
9531cb0ef41Sopenharmony_ci      config,
9541cb0ef41Sopenharmony_ci      prefixDir: {
9551cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
9561cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
9571cb0ef41Sopenharmony_ci          version: '1.0.0',
9581cb0ef41Sopenharmony_ci          dependencies: {
9591cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
9601cb0ef41Sopenharmony_ci            chai: '^1.0.0',
9611cb0ef41Sopenharmony_ci          },
9621cb0ef41Sopenharmony_ci          devDependencies: {
9631cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
9641cb0ef41Sopenharmony_ci          },
9651cb0ef41Sopenharmony_ci          optionalDependencies: {
9661cb0ef41Sopenharmony_ci            'missing-optional-dep': '^1.0.0',
9671cb0ef41Sopenharmony_ci            'optional-dep': '^2.0.0', // mismatching version #
9681cb0ef41Sopenharmony_ci          },
9691cb0ef41Sopenharmony_ci          peerDependencies: {
9701cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
9711cb0ef41Sopenharmony_ci          },
9721cb0ef41Sopenharmony_ci        }),
9731cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
9741cb0ef41Sopenharmony_ci      },
9751cb0ef41Sopenharmony_ci    })
9761cb0ef41Sopenharmony_ci    await t.rejects(
9771cb0ef41Sopenharmony_ci      ls.exec([]),
9781cb0ef41Sopenharmony_ci      { code: 'ELSPROBLEMS', message: /invalid: optional-dep@1.0.0/ },
9791cb0ef41Sopenharmony_ci      'should have invalid dep error msg'
9801cb0ef41Sopenharmony_ci    )
9811cb0ef41Sopenharmony_ci    t.matchSnapshot(
9821cb0ef41Sopenharmony_ci      cleanCwd(result()),
9831cb0ef41Sopenharmony_ci      'should output tree with empty entry for missing optional deps'
9841cb0ef41Sopenharmony_ci    )
9851cb0ef41Sopenharmony_ci  })
9861cb0ef41Sopenharmony_ci
9871cb0ef41Sopenharmony_ci  t.test('cycle deps', async t => {
9881cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
9891cb0ef41Sopenharmony_ci      config: {},
9901cb0ef41Sopenharmony_ci      prefixDir: {
9911cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
9921cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
9931cb0ef41Sopenharmony_ci          version: '1.0.0',
9941cb0ef41Sopenharmony_ci          dependencies: {
9951cb0ef41Sopenharmony_ci            a: '^1.0.0',
9961cb0ef41Sopenharmony_ci          },
9971cb0ef41Sopenharmony_ci        }),
9981cb0ef41Sopenharmony_ci        node_modules: {
9991cb0ef41Sopenharmony_ci          a: {
10001cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
10011cb0ef41Sopenharmony_ci              name: 'a',
10021cb0ef41Sopenharmony_ci              version: '1.0.0',
10031cb0ef41Sopenharmony_ci              dependencies: {
10041cb0ef41Sopenharmony_ci                b: '^1.0.0',
10051cb0ef41Sopenharmony_ci              },
10061cb0ef41Sopenharmony_ci            }),
10071cb0ef41Sopenharmony_ci          },
10081cb0ef41Sopenharmony_ci          b: {
10091cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
10101cb0ef41Sopenharmony_ci              name: 'b',
10111cb0ef41Sopenharmony_ci              version: '1.0.0',
10121cb0ef41Sopenharmony_ci              dependencies: {
10131cb0ef41Sopenharmony_ci                a: '^1.0.0',
10141cb0ef41Sopenharmony_ci              },
10151cb0ef41Sopenharmony_ci            }),
10161cb0ef41Sopenharmony_ci          },
10171cb0ef41Sopenharmony_ci        },
10181cb0ef41Sopenharmony_ci      },
10191cb0ef41Sopenharmony_ci    })
10201cb0ef41Sopenharmony_ci    await ls.exec([])
10211cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print tree output containing deduped ref')
10221cb0ef41Sopenharmony_ci  })
10231cb0ef41Sopenharmony_ci
10241cb0ef41Sopenharmony_ci  t.test('cycle deps with filter args', async t => {
10251cb0ef41Sopenharmony_ci    const config = { color: 'always' }
10261cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
10271cb0ef41Sopenharmony_ci      config,
10281cb0ef41Sopenharmony_ci      prefixDir: {
10291cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
10301cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
10311cb0ef41Sopenharmony_ci          version: '1.0.0',
10321cb0ef41Sopenharmony_ci          dependencies: {
10331cb0ef41Sopenharmony_ci            a: '^1.0.0',
10341cb0ef41Sopenharmony_ci          },
10351cb0ef41Sopenharmony_ci        }),
10361cb0ef41Sopenharmony_ci        node_modules: {
10371cb0ef41Sopenharmony_ci          a: {
10381cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
10391cb0ef41Sopenharmony_ci              name: 'a',
10401cb0ef41Sopenharmony_ci              version: '1.0.0',
10411cb0ef41Sopenharmony_ci              dependencies: {
10421cb0ef41Sopenharmony_ci                b: '^1.0.0',
10431cb0ef41Sopenharmony_ci              },
10441cb0ef41Sopenharmony_ci            }),
10451cb0ef41Sopenharmony_ci          },
10461cb0ef41Sopenharmony_ci          b: {
10471cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
10481cb0ef41Sopenharmony_ci              name: 'b',
10491cb0ef41Sopenharmony_ci              version: '1.0.0',
10501cb0ef41Sopenharmony_ci              dependencies: {
10511cb0ef41Sopenharmony_ci                a: '^1.0.0',
10521cb0ef41Sopenharmony_ci              },
10531cb0ef41Sopenharmony_ci            }),
10541cb0ef41Sopenharmony_ci          },
10551cb0ef41Sopenharmony_ci        },
10561cb0ef41Sopenharmony_ci      },
10571cb0ef41Sopenharmony_ci    })
10581cb0ef41Sopenharmony_ci    await ls.exec(['a'])
10591cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print tree output containing deduped ref')
10601cb0ef41Sopenharmony_ci  })
10611cb0ef41Sopenharmony_ci
10621cb0ef41Sopenharmony_ci  t.test('with no args dedupe entries', async t => {
10631cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
10641cb0ef41Sopenharmony_ci      config: {},
10651cb0ef41Sopenharmony_ci      prefixDir: {
10661cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
10671cb0ef41Sopenharmony_ci          name: 'dedupe-entries',
10681cb0ef41Sopenharmony_ci          version: '1.0.0',
10691cb0ef41Sopenharmony_ci          dependencies: {
10701cb0ef41Sopenharmony_ci            '@npmcli/a': '^1.0.0',
10711cb0ef41Sopenharmony_ci            '@npmcli/b': '^1.0.0',
10721cb0ef41Sopenharmony_ci            '@npmcli/c': '^1.0.0',
10731cb0ef41Sopenharmony_ci          },
10741cb0ef41Sopenharmony_ci        }),
10751cb0ef41Sopenharmony_ci        node_modules: {
10761cb0ef41Sopenharmony_ci          '@npmcli': {
10771cb0ef41Sopenharmony_ci            a: {
10781cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
10791cb0ef41Sopenharmony_ci                name: '@npmcli/a',
10801cb0ef41Sopenharmony_ci                version: '1.0.0',
10811cb0ef41Sopenharmony_ci                dependencies: {
10821cb0ef41Sopenharmony_ci                  '@npmcli/b': '^1.0.0',
10831cb0ef41Sopenharmony_ci                },
10841cb0ef41Sopenharmony_ci              }),
10851cb0ef41Sopenharmony_ci            },
10861cb0ef41Sopenharmony_ci            b: {
10871cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
10881cb0ef41Sopenharmony_ci                name: '@npmcli/b',
10891cb0ef41Sopenharmony_ci                version: '1.1.2',
10901cb0ef41Sopenharmony_ci              }),
10911cb0ef41Sopenharmony_ci            },
10921cb0ef41Sopenharmony_ci            c: {
10931cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
10941cb0ef41Sopenharmony_ci                name: '@npmcli/c',
10951cb0ef41Sopenharmony_ci                version: '1.0.0',
10961cb0ef41Sopenharmony_ci                dependencies: {
10971cb0ef41Sopenharmony_ci                  '@npmcli/b': '^1.0.0',
10981cb0ef41Sopenharmony_ci                },
10991cb0ef41Sopenharmony_ci              }),
11001cb0ef41Sopenharmony_ci            },
11011cb0ef41Sopenharmony_ci          },
11021cb0ef41Sopenharmony_ci        },
11031cb0ef41Sopenharmony_ci      },
11041cb0ef41Sopenharmony_ci    })
11051cb0ef41Sopenharmony_ci    await ls.exec([])
11061cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print tree output containing deduped ref')
11071cb0ef41Sopenharmony_ci  })
11081cb0ef41Sopenharmony_ci
11091cb0ef41Sopenharmony_ci  t.test('with no args dedupe entries and not displaying all', async t => {
11101cb0ef41Sopenharmony_ci    const config = {
11111cb0ef41Sopenharmony_ci      all: false,
11121cb0ef41Sopenharmony_ci      depth: 0,
11131cb0ef41Sopenharmony_ci    }
11141cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
11151cb0ef41Sopenharmony_ci      config,
11161cb0ef41Sopenharmony_ci      prefixDir: {
11171cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
11181cb0ef41Sopenharmony_ci          name: 'dedupe-entries',
11191cb0ef41Sopenharmony_ci          version: '1.0.0',
11201cb0ef41Sopenharmony_ci          dependencies: {
11211cb0ef41Sopenharmony_ci            '@npmcli/a': '^1.0.0',
11221cb0ef41Sopenharmony_ci            '@npmcli/b': '^1.0.0',
11231cb0ef41Sopenharmony_ci            '@npmcli/c': '^1.0.0',
11241cb0ef41Sopenharmony_ci          },
11251cb0ef41Sopenharmony_ci        }),
11261cb0ef41Sopenharmony_ci        node_modules: {
11271cb0ef41Sopenharmony_ci          '@npmcli': {
11281cb0ef41Sopenharmony_ci            a: {
11291cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
11301cb0ef41Sopenharmony_ci                name: '@npmcli/a',
11311cb0ef41Sopenharmony_ci                version: '1.0.0',
11321cb0ef41Sopenharmony_ci                dependencies: {
11331cb0ef41Sopenharmony_ci                  '@npmcli/b': '^1.0.0',
11341cb0ef41Sopenharmony_ci                },
11351cb0ef41Sopenharmony_ci              }),
11361cb0ef41Sopenharmony_ci            },
11371cb0ef41Sopenharmony_ci            b: {
11381cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
11391cb0ef41Sopenharmony_ci                name: '@npmcli/b',
11401cb0ef41Sopenharmony_ci                version: '1.1.2',
11411cb0ef41Sopenharmony_ci              }),
11421cb0ef41Sopenharmony_ci            },
11431cb0ef41Sopenharmony_ci            c: {
11441cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
11451cb0ef41Sopenharmony_ci                name: '@npmcli/c',
11461cb0ef41Sopenharmony_ci                version: '1.0.0',
11471cb0ef41Sopenharmony_ci                dependencies: {
11481cb0ef41Sopenharmony_ci                  '@npmcli/b': '^1.0.0',
11491cb0ef41Sopenharmony_ci                },
11501cb0ef41Sopenharmony_ci              }),
11511cb0ef41Sopenharmony_ci            },
11521cb0ef41Sopenharmony_ci          },
11531cb0ef41Sopenharmony_ci        },
11541cb0ef41Sopenharmony_ci      },
11551cb0ef41Sopenharmony_ci    })
11561cb0ef41Sopenharmony_ci    await ls.exec([])
11571cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print tree output containing deduped ref')
11581cb0ef41Sopenharmony_ci  })
11591cb0ef41Sopenharmony_ci
11601cb0ef41Sopenharmony_ci  t.test('with args and dedupe entries', async t => {
11611cb0ef41Sopenharmony_ci    const config = { color: 'always' }
11621cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
11631cb0ef41Sopenharmony_ci      config,
11641cb0ef41Sopenharmony_ci      prefixDir: {
11651cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
11661cb0ef41Sopenharmony_ci          name: 'dedupe-entries',
11671cb0ef41Sopenharmony_ci          version: '1.0.0',
11681cb0ef41Sopenharmony_ci          dependencies: {
11691cb0ef41Sopenharmony_ci            '@npmcli/a': '^1.0.0',
11701cb0ef41Sopenharmony_ci            '@npmcli/b': '^1.0.0',
11711cb0ef41Sopenharmony_ci            '@npmcli/c': '^1.0.0',
11721cb0ef41Sopenharmony_ci          },
11731cb0ef41Sopenharmony_ci        }),
11741cb0ef41Sopenharmony_ci        node_modules: {
11751cb0ef41Sopenharmony_ci          '@npmcli': {
11761cb0ef41Sopenharmony_ci            a: {
11771cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
11781cb0ef41Sopenharmony_ci                name: '@npmcli/a',
11791cb0ef41Sopenharmony_ci                version: '1.0.0',
11801cb0ef41Sopenharmony_ci                dependencies: {
11811cb0ef41Sopenharmony_ci                  '@npmcli/b': '^1.0.0',
11821cb0ef41Sopenharmony_ci                },
11831cb0ef41Sopenharmony_ci              }),
11841cb0ef41Sopenharmony_ci            },
11851cb0ef41Sopenharmony_ci            b: {
11861cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
11871cb0ef41Sopenharmony_ci                name: '@npmcli/b',
11881cb0ef41Sopenharmony_ci                version: '1.1.2',
11891cb0ef41Sopenharmony_ci              }),
11901cb0ef41Sopenharmony_ci            },
11911cb0ef41Sopenharmony_ci            c: {
11921cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
11931cb0ef41Sopenharmony_ci                name: '@npmcli/c',
11941cb0ef41Sopenharmony_ci                version: '1.0.0',
11951cb0ef41Sopenharmony_ci                dependencies: {
11961cb0ef41Sopenharmony_ci                  '@npmcli/b': '^1.0.0',
11971cb0ef41Sopenharmony_ci                },
11981cb0ef41Sopenharmony_ci              }),
11991cb0ef41Sopenharmony_ci            },
12001cb0ef41Sopenharmony_ci          },
12011cb0ef41Sopenharmony_ci        },
12021cb0ef41Sopenharmony_ci      },
12031cb0ef41Sopenharmony_ci    })
12041cb0ef41Sopenharmony_ci    await ls.exec(['@npmcli/b'])
12051cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print tree output containing deduped ref')
12061cb0ef41Sopenharmony_ci  })
12071cb0ef41Sopenharmony_ci
12081cb0ef41Sopenharmony_ci  t.test('with args and different order of items', async t => {
12091cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
12101cb0ef41Sopenharmony_ci      config: {},
12111cb0ef41Sopenharmony_ci      prefixDir: {
12121cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
12131cb0ef41Sopenharmony_ci          name: 'dedupe-entries',
12141cb0ef41Sopenharmony_ci          version: '1.0.0',
12151cb0ef41Sopenharmony_ci          dependencies: {
12161cb0ef41Sopenharmony_ci            '@npmcli/a': '^1.0.0',
12171cb0ef41Sopenharmony_ci            '@npmcli/b': '^1.0.0',
12181cb0ef41Sopenharmony_ci            '@npmcli/c': '^1.0.0',
12191cb0ef41Sopenharmony_ci          },
12201cb0ef41Sopenharmony_ci        }),
12211cb0ef41Sopenharmony_ci        node_modules: {
12221cb0ef41Sopenharmony_ci          '@npmcli': {
12231cb0ef41Sopenharmony_ci            a: {
12241cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
12251cb0ef41Sopenharmony_ci                name: '@npmcli/a',
12261cb0ef41Sopenharmony_ci                version: '1.0.0',
12271cb0ef41Sopenharmony_ci                dependencies: {
12281cb0ef41Sopenharmony_ci                  '@npmcli/c': '^1.0.0',
12291cb0ef41Sopenharmony_ci                },
12301cb0ef41Sopenharmony_ci              }),
12311cb0ef41Sopenharmony_ci            },
12321cb0ef41Sopenharmony_ci            b: {
12331cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
12341cb0ef41Sopenharmony_ci                name: '@npmcli/b',
12351cb0ef41Sopenharmony_ci                version: '1.1.2',
12361cb0ef41Sopenharmony_ci                dependencies: {
12371cb0ef41Sopenharmony_ci                  '@npmcli/c': '^1.0.0',
12381cb0ef41Sopenharmony_ci                },
12391cb0ef41Sopenharmony_ci              }),
12401cb0ef41Sopenharmony_ci            },
12411cb0ef41Sopenharmony_ci            c: {
12421cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
12431cb0ef41Sopenharmony_ci                name: '@npmcli/c',
12441cb0ef41Sopenharmony_ci                version: '1.0.0',
12451cb0ef41Sopenharmony_ci              }),
12461cb0ef41Sopenharmony_ci            },
12471cb0ef41Sopenharmony_ci          },
12481cb0ef41Sopenharmony_ci        },
12491cb0ef41Sopenharmony_ci      },
12501cb0ef41Sopenharmony_ci    })
12511cb0ef41Sopenharmony_ci    await ls.exec(['@npmcli/c'])
12521cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print tree output containing deduped ref')
12531cb0ef41Sopenharmony_ci  })
12541cb0ef41Sopenharmony_ci
12551cb0ef41Sopenharmony_ci  t.test('using aliases', async t => {
12561cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
12571cb0ef41Sopenharmony_ci      config: {},
12581cb0ef41Sopenharmony_ci      prefixDir: {
12591cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
12601cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
12611cb0ef41Sopenharmony_ci          version: '1.0.0',
12621cb0ef41Sopenharmony_ci          dependencies: {
12631cb0ef41Sopenharmony_ci            a: 'npm:b@1.0.0',
12641cb0ef41Sopenharmony_ci          },
12651cb0ef41Sopenharmony_ci        }),
12661cb0ef41Sopenharmony_ci        node_modules: {
12671cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
12681cb0ef41Sopenharmony_ci            packages: {
12691cb0ef41Sopenharmony_ci              'node_modules/a': {
12701cb0ef41Sopenharmony_ci                name: 'b',
12711cb0ef41Sopenharmony_ci                version: '1.0.0',
12721cb0ef41Sopenharmony_ci                from: 'a@npm:b',
12731cb0ef41Sopenharmony_ci                resolved: 'https://localhost:8080/abbrev/-/abbrev-1.1.1.tgz',
12741cb0ef41Sopenharmony_ci                requested: {
12751cb0ef41Sopenharmony_ci                  type: 'alias',
12761cb0ef41Sopenharmony_ci                },
12771cb0ef41Sopenharmony_ci              },
12781cb0ef41Sopenharmony_ci            },
12791cb0ef41Sopenharmony_ci          }),
12801cb0ef41Sopenharmony_ci          a: {
12811cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
12821cb0ef41Sopenharmony_ci              name: 'b',
12831cb0ef41Sopenharmony_ci              version: '1.0.0',
12841cb0ef41Sopenharmony_ci              _from: 'a@npm:b',
12851cb0ef41Sopenharmony_ci              _resolved: 'https://localhost:8080/abbrev/-/abbrev-1.1.1.tgz',
12861cb0ef41Sopenharmony_ci              _requested: {
12871cb0ef41Sopenharmony_ci                type: 'alias',
12881cb0ef41Sopenharmony_ci              },
12891cb0ef41Sopenharmony_ci            }),
12901cb0ef41Sopenharmony_ci          },
12911cb0ef41Sopenharmony_ci        },
12921cb0ef41Sopenharmony_ci      },
12931cb0ef41Sopenharmony_ci    })
12941cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
12951cb0ef41Sopenharmony_ci    await ls.exec([])
12961cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing aliases')
12971cb0ef41Sopenharmony_ci  })
12981cb0ef41Sopenharmony_ci
12991cb0ef41Sopenharmony_ci  t.test('resolved points to git ref', async t => {
13001cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
13011cb0ef41Sopenharmony_ci      config: {},
13021cb0ef41Sopenharmony_ci      prefixDir: {
13031cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
13041cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
13051cb0ef41Sopenharmony_ci          version: '1.0.0',
13061cb0ef41Sopenharmony_ci          dependencies: {
13071cb0ef41Sopenharmony_ci            abbrev: 'git+https://github.com/isaacs/abbrev-js.git',
13081cb0ef41Sopenharmony_ci          },
13091cb0ef41Sopenharmony_ci        }),
13101cb0ef41Sopenharmony_ci        node_modules: {
13111cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
13121cb0ef41Sopenharmony_ci            packages: {
13131cb0ef41Sopenharmony_ci              'node_modules/abbrev': {
13141cb0ef41Sopenharmony_ci                name: 'abbrev',
13151cb0ef41Sopenharmony_ci                version: '1.1.1',
13161cb0ef41Sopenharmony_ci                from: 'git+https://github.com/isaacs/abbrev-js.git',
13171cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
13181cb0ef41Sopenharmony_ci                resolved: 'git+https://github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
13191cb0ef41Sopenharmony_ci              },
13201cb0ef41Sopenharmony_ci            },
13211cb0ef41Sopenharmony_ci          }),
13221cb0ef41Sopenharmony_ci          abbrev: {
13231cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
13241cb0ef41Sopenharmony_ci              name: 'abbrev',
13251cb0ef41Sopenharmony_ci              version: '1.1.1',
13261cb0ef41Sopenharmony_ci              _id: 'abbrev@1.1.1',
13271cb0ef41Sopenharmony_ci              _from: 'git+https://github.com/isaacs/abbrev-js.git',
13281cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
13291cb0ef41Sopenharmony_ci              _resolved: 'git+https://github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
13301cb0ef41Sopenharmony_ci              _requested: {
13311cb0ef41Sopenharmony_ci                type: 'git',
13321cb0ef41Sopenharmony_ci                raw: 'git+https:github.com/isaacs/abbrev-js.git',
13331cb0ef41Sopenharmony_ci                rawSpec: 'git+https:github.com/isaacs/abbrev-js.git',
13341cb0ef41Sopenharmony_ci                saveSpec: 'git+https://github.com/isaacs/abbrev-js.git',
13351cb0ef41Sopenharmony_ci                fetchSpec: 'https://github.com/isaacs/abbrev-js.git',
13361cb0ef41Sopenharmony_ci                gitCommittish: null,
13371cb0ef41Sopenharmony_ci              },
13381cb0ef41Sopenharmony_ci            }),
13391cb0ef41Sopenharmony_ci          },
13401cb0ef41Sopenharmony_ci        },
13411cb0ef41Sopenharmony_ci      },
13421cb0ef41Sopenharmony_ci    })
13431cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
13441cb0ef41Sopenharmony_ci    await ls.exec([])
13451cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing git refs')
13461cb0ef41Sopenharmony_ci  })
13471cb0ef41Sopenharmony_ci
13481cb0ef41Sopenharmony_ci  t.test('broken resolved field', async t => {
13491cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
13501cb0ef41Sopenharmony_ci      config: {},
13511cb0ef41Sopenharmony_ci      prefixDir: {
13521cb0ef41Sopenharmony_ci        node_modules: {
13531cb0ef41Sopenharmony_ci          a: {
13541cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
13551cb0ef41Sopenharmony_ci              name: 'a',
13561cb0ef41Sopenharmony_ci              version: '1.0.1',
13571cb0ef41Sopenharmony_ci            }),
13581cb0ef41Sopenharmony_ci          },
13591cb0ef41Sopenharmony_ci        },
13601cb0ef41Sopenharmony_ci        'package-lock.json': JSON.stringify({
13611cb0ef41Sopenharmony_ci          name: 'npm-broken-resolved-field-test',
13621cb0ef41Sopenharmony_ci          version: '1.0.0',
13631cb0ef41Sopenharmony_ci          lockfileVersion: 2,
13641cb0ef41Sopenharmony_ci          requires: true,
13651cb0ef41Sopenharmony_ci          packages: {
13661cb0ef41Sopenharmony_ci            '': {
13671cb0ef41Sopenharmony_ci              name: 'a',
13681cb0ef41Sopenharmony_ci              version: '1.0.1',
13691cb0ef41Sopenharmony_ci            },
13701cb0ef41Sopenharmony_ci          },
13711cb0ef41Sopenharmony_ci          dependencies: {
13721cb0ef41Sopenharmony_ci            a: {
13731cb0ef41Sopenharmony_ci              version: '1.0.1',
13741cb0ef41Sopenharmony_ci              resolved: 'foo@dog://b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
13751cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
13761cb0ef41Sopenharmony_ci              integrity: 'sha512-8AN9lNCcBt5Xeje7fMEEpp5K3rgcAzIpTtAjYb/YMUYu8SbIVF6wz0WqACDVKvpQOUcSfNHZQNLNmue0QSwXOQ==',
13771cb0ef41Sopenharmony_ci            },
13781cb0ef41Sopenharmony_ci          },
13791cb0ef41Sopenharmony_ci        }),
13801cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
13811cb0ef41Sopenharmony_ci          name: 'npm-broken-resolved-field-test',
13821cb0ef41Sopenharmony_ci          version: '1.0.0',
13831cb0ef41Sopenharmony_ci          dependencies: {
13841cb0ef41Sopenharmony_ci            a: '^1.0.1',
13851cb0ef41Sopenharmony_ci          },
13861cb0ef41Sopenharmony_ci        }),
13871cb0ef41Sopenharmony_ci      },
13881cb0ef41Sopenharmony_ci    })
13891cb0ef41Sopenharmony_ci    await ls.exec([])
13901cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should NOT print git refs in output tree')
13911cb0ef41Sopenharmony_ci  })
13921cb0ef41Sopenharmony_ci
13931cb0ef41Sopenharmony_ci  t.test('from and resolved properties', async t => {
13941cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
13951cb0ef41Sopenharmony_ci      config: {},
13961cb0ef41Sopenharmony_ci      prefixDir: {
13971cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
13981cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
13991cb0ef41Sopenharmony_ci          version: '1.0.0',
14001cb0ef41Sopenharmony_ci          dependencies: {
14011cb0ef41Sopenharmony_ci            'simple-output': '^2.0.0',
14021cb0ef41Sopenharmony_ci          },
14031cb0ef41Sopenharmony_ci        }),
14041cb0ef41Sopenharmony_ci        node_modules: {
14051cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
14061cb0ef41Sopenharmony_ci            packages: {
14071cb0ef41Sopenharmony_ci              'node_modules/simple-output': {
14081cb0ef41Sopenharmony_ci                name: 'simple-output',
14091cb0ef41Sopenharmony_ci                version: '2.1.1',
14101cb0ef41Sopenharmony_ci                resolved: 'https://registry.npmjs.org/simple-output/-/simple-output-2.1.1.tgz',
14111cb0ef41Sopenharmony_ci                shasum: '3c07708ec9ef3e3c985cf0ddd67df09ab8ec2abc',
14121cb0ef41Sopenharmony_ci              },
14131cb0ef41Sopenharmony_ci            },
14141cb0ef41Sopenharmony_ci          }),
14151cb0ef41Sopenharmony_ci          'simple-output': {
14161cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
14171cb0ef41Sopenharmony_ci              name: 'simple-output',
14181cb0ef41Sopenharmony_ci              version: '2.1.1',
14191cb0ef41Sopenharmony_ci              _from: 'simple-output',
14201cb0ef41Sopenharmony_ci              _id: 'simple-output@2.1.1',
14211cb0ef41Sopenharmony_ci              _resolved: 'https://registry.npmjs.org/simple-output/-/simple-output-2.1.1.tgz',
14221cb0ef41Sopenharmony_ci              _requested: {
14231cb0ef41Sopenharmony_ci                type: 'tag',
14241cb0ef41Sopenharmony_ci                registry: true,
14251cb0ef41Sopenharmony_ci                raw: 'simple-output',
14261cb0ef41Sopenharmony_ci                name: 'simple-output',
14271cb0ef41Sopenharmony_ci                escapedName: 'simple-output',
14281cb0ef41Sopenharmony_ci                rawSpec: '',
14291cb0ef41Sopenharmony_ci                saveSpec: null,
14301cb0ef41Sopenharmony_ci                fetchSpec: 'latest',
14311cb0ef41Sopenharmony_ci              },
14321cb0ef41Sopenharmony_ci              _requiredBy: ['#USER', '/'],
14331cb0ef41Sopenharmony_ci              _shasum: '3c07708ec9ef3e3c985cf0ddd67df09ab8ec2abc',
14341cb0ef41Sopenharmony_ci              _spec: 'simple-output',
14351cb0ef41Sopenharmony_ci            }),
14361cb0ef41Sopenharmony_ci          },
14371cb0ef41Sopenharmony_ci        },
14381cb0ef41Sopenharmony_ci      },
14391cb0ef41Sopenharmony_ci    })
14401cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
14411cb0ef41Sopenharmony_ci    await ls.exec([])
14421cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should not be printed in tree output')
14431cb0ef41Sopenharmony_ci  })
14441cb0ef41Sopenharmony_ci
14451cb0ef41Sopenharmony_ci  t.test('global', async t => {
14461cb0ef41Sopenharmony_ci    const config = {
14471cb0ef41Sopenharmony_ci      global: true,
14481cb0ef41Sopenharmony_ci    }
14491cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
14501cb0ef41Sopenharmony_ci      config,
14511cb0ef41Sopenharmony_ci      globalPrefixDir: {
14521cb0ef41Sopenharmony_ci        node_modules: {
14531cb0ef41Sopenharmony_ci          a: {
14541cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
14551cb0ef41Sopenharmony_ci              name: 'a',
14561cb0ef41Sopenharmony_ci              version: '1.0.0',
14571cb0ef41Sopenharmony_ci            }),
14581cb0ef41Sopenharmony_ci          },
14591cb0ef41Sopenharmony_ci          b: {
14601cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
14611cb0ef41Sopenharmony_ci              name: 'b',
14621cb0ef41Sopenharmony_ci              version: '1.0.0',
14631cb0ef41Sopenharmony_ci            }),
14641cb0ef41Sopenharmony_ci            node_modules: {
14651cb0ef41Sopenharmony_ci              c: {
14661cb0ef41Sopenharmony_ci                'package.json': JSON.stringify({
14671cb0ef41Sopenharmony_ci                  name: 'c',
14681cb0ef41Sopenharmony_ci                  version: '1.0.0',
14691cb0ef41Sopenharmony_ci                }),
14701cb0ef41Sopenharmony_ci              },
14711cb0ef41Sopenharmony_ci            },
14721cb0ef41Sopenharmony_ci          },
14731cb0ef41Sopenharmony_ci        },
14741cb0ef41Sopenharmony_ci      },
14751cb0ef41Sopenharmony_ci    })
14761cb0ef41Sopenharmony_ci
14771cb0ef41Sopenharmony_ci    await ls.exec([])
14781cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()),
14791cb0ef41Sopenharmony_ci      'should print tree and not mark top-level items extraneous')
14801cb0ef41Sopenharmony_ci  })
14811cb0ef41Sopenharmony_ci
14821cb0ef41Sopenharmony_ci  t.test('filtering by child of missing dep', async t => {
14831cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
14841cb0ef41Sopenharmony_ci      config: {},
14851cb0ef41Sopenharmony_ci      prefixDir: {
14861cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
14871cb0ef41Sopenharmony_ci          name: 'filter-by-child-of-missing-dep',
14881cb0ef41Sopenharmony_ci          version: '1.0.0',
14891cb0ef41Sopenharmony_ci          dependencies: {
14901cb0ef41Sopenharmony_ci            a: '^1.0.0',
14911cb0ef41Sopenharmony_ci          },
14921cb0ef41Sopenharmony_ci        }),
14931cb0ef41Sopenharmony_ci        node_modules: {
14941cb0ef41Sopenharmony_ci          b: {
14951cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
14961cb0ef41Sopenharmony_ci              name: 'b',
14971cb0ef41Sopenharmony_ci              version: '1.0.0',
14981cb0ef41Sopenharmony_ci              dependencies: {
14991cb0ef41Sopenharmony_ci                c: '^1.0.0',
15001cb0ef41Sopenharmony_ci              },
15011cb0ef41Sopenharmony_ci            }),
15021cb0ef41Sopenharmony_ci          },
15031cb0ef41Sopenharmony_ci          c: {
15041cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
15051cb0ef41Sopenharmony_ci              name: 'c',
15061cb0ef41Sopenharmony_ci              version: '1.0.0',
15071cb0ef41Sopenharmony_ci            }),
15081cb0ef41Sopenharmony_ci          },
15091cb0ef41Sopenharmony_ci          d: {
15101cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
15111cb0ef41Sopenharmony_ci              name: 'd',
15121cb0ef41Sopenharmony_ci              version: '1.0.0',
15131cb0ef41Sopenharmony_ci              dependencies: {
15141cb0ef41Sopenharmony_ci                c: '^2.0.0',
15151cb0ef41Sopenharmony_ci              },
15161cb0ef41Sopenharmony_ci            }),
15171cb0ef41Sopenharmony_ci            node_modules: {
15181cb0ef41Sopenharmony_ci              c: {
15191cb0ef41Sopenharmony_ci                'package.json': JSON.stringify({
15201cb0ef41Sopenharmony_ci                  name: 'c',
15211cb0ef41Sopenharmony_ci                  version: '2.0.0',
15221cb0ef41Sopenharmony_ci                }),
15231cb0ef41Sopenharmony_ci              },
15241cb0ef41Sopenharmony_ci            },
15251cb0ef41Sopenharmony_ci          },
15261cb0ef41Sopenharmony_ci        },
15271cb0ef41Sopenharmony_ci      },
15281cb0ef41Sopenharmony_ci    })
15291cb0ef41Sopenharmony_ci
15301cb0ef41Sopenharmony_ci    await ls.exec(['c'])
15311cb0ef41Sopenharmony_ci    t.matchSnapshot(
15321cb0ef41Sopenharmony_ci      cleanCwd(result()),
15331cb0ef41Sopenharmony_ci      'should print tree and not duplicate child of missing items'
15341cb0ef41Sopenharmony_ci    )
15351cb0ef41Sopenharmony_ci  })
15361cb0ef41Sopenharmony_ci
15371cb0ef41Sopenharmony_ci  t.test('loading a tree containing workspaces', async t => {
15381cb0ef41Sopenharmony_ci    const mockWorkspaces = async (t, exec = [], config = {}) => {
15391cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
15401cb0ef41Sopenharmony_ci        config,
15411cb0ef41Sopenharmony_ci        prefixDir: {
15421cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
15431cb0ef41Sopenharmony_ci            name: 'workspaces-tree',
15441cb0ef41Sopenharmony_ci            version: '1.0.0',
15451cb0ef41Sopenharmony_ci            workspaces: ['./a', './b', './d', './group/*'],
15461cb0ef41Sopenharmony_ci            dependencies: { pacote: '1.0.0' },
15471cb0ef41Sopenharmony_ci          }),
15481cb0ef41Sopenharmony_ci          node_modules: {
15491cb0ef41Sopenharmony_ci            a: t.fixture('symlink', '../a'),
15501cb0ef41Sopenharmony_ci            b: t.fixture('symlink', '../b'),
15511cb0ef41Sopenharmony_ci            c: {
15521cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
15531cb0ef41Sopenharmony_ci                name: 'c',
15541cb0ef41Sopenharmony_ci                version: '1.0.0',
15551cb0ef41Sopenharmony_ci              }),
15561cb0ef41Sopenharmony_ci            },
15571cb0ef41Sopenharmony_ci            d: t.fixture('symlink', '../d'),
15581cb0ef41Sopenharmony_ci            e: t.fixture('symlink', '../group/e'),
15591cb0ef41Sopenharmony_ci            f: t.fixture('symlink', '../group/f'),
15601cb0ef41Sopenharmony_ci            foo: {
15611cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
15621cb0ef41Sopenharmony_ci                name: 'foo',
15631cb0ef41Sopenharmony_ci                version: '1.1.1',
15641cb0ef41Sopenharmony_ci                dependencies: {
15651cb0ef41Sopenharmony_ci                  bar: '^1.0.0',
15661cb0ef41Sopenharmony_ci                },
15671cb0ef41Sopenharmony_ci              }),
15681cb0ef41Sopenharmony_ci            },
15691cb0ef41Sopenharmony_ci            bar: {
15701cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({ name: 'bar', version: '1.0.0' }),
15711cb0ef41Sopenharmony_ci            },
15721cb0ef41Sopenharmony_ci            baz: {
15731cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({ name: 'baz', version: '1.0.0' }),
15741cb0ef41Sopenharmony_ci            },
15751cb0ef41Sopenharmony_ci            pacote: {
15761cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({ name: 'pacote', version: '1.0.0' }),
15771cb0ef41Sopenharmony_ci            },
15781cb0ef41Sopenharmony_ci          },
15791cb0ef41Sopenharmony_ci          a: {
15801cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
15811cb0ef41Sopenharmony_ci              name: 'a',
15821cb0ef41Sopenharmony_ci              version: '1.0.0',
15831cb0ef41Sopenharmony_ci              dependencies: {
15841cb0ef41Sopenharmony_ci                c: '^1.0.0',
15851cb0ef41Sopenharmony_ci                d: '^1.0.0',
15861cb0ef41Sopenharmony_ci              },
15871cb0ef41Sopenharmony_ci              devDependencies: {
15881cb0ef41Sopenharmony_ci                baz: '^1.0.0',
15891cb0ef41Sopenharmony_ci              },
15901cb0ef41Sopenharmony_ci            }),
15911cb0ef41Sopenharmony_ci          },
15921cb0ef41Sopenharmony_ci          b: {
15931cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
15941cb0ef41Sopenharmony_ci              name: 'b',
15951cb0ef41Sopenharmony_ci              version: '1.0.0',
15961cb0ef41Sopenharmony_ci            }),
15971cb0ef41Sopenharmony_ci          },
15981cb0ef41Sopenharmony_ci          d: {
15991cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
16001cb0ef41Sopenharmony_ci              name: 'd',
16011cb0ef41Sopenharmony_ci              version: '1.0.0',
16021cb0ef41Sopenharmony_ci              dependencies: {
16031cb0ef41Sopenharmony_ci                foo: '^1.1.1',
16041cb0ef41Sopenharmony_ci              },
16051cb0ef41Sopenharmony_ci            }),
16061cb0ef41Sopenharmony_ci          },
16071cb0ef41Sopenharmony_ci          group: {
16081cb0ef41Sopenharmony_ci            e: {
16091cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
16101cb0ef41Sopenharmony_ci                name: 'e',
16111cb0ef41Sopenharmony_ci                version: '1.0.0',
16121cb0ef41Sopenharmony_ci              }),
16131cb0ef41Sopenharmony_ci            },
16141cb0ef41Sopenharmony_ci            f: {
16151cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
16161cb0ef41Sopenharmony_ci                name: 'f',
16171cb0ef41Sopenharmony_ci                version: '1.0.0',
16181cb0ef41Sopenharmony_ci              }),
16191cb0ef41Sopenharmony_ci            },
16201cb0ef41Sopenharmony_ci          },
16211cb0ef41Sopenharmony_ci        },
16221cb0ef41Sopenharmony_ci      })
16231cb0ef41Sopenharmony_ci
16241cb0ef41Sopenharmony_ci      await ls.exec(exec)
16251cb0ef41Sopenharmony_ci
16261cb0ef41Sopenharmony_ci      t.matchSnapshot(cleanCwd(result(), t), 'output')
16271cb0ef41Sopenharmony_ci    }
16281cb0ef41Sopenharmony_ci
16291cb0ef41Sopenharmony_ci    t.test('should list workspaces properly with default configs', t => mockWorkspaces(t, [], {
16301cb0ef41Sopenharmony_ci      depth: 0,
16311cb0ef41Sopenharmony_ci      color: 'always',
16321cb0ef41Sopenharmony_ci    }))
16331cb0ef41Sopenharmony_ci
16341cb0ef41Sopenharmony_ci    t.test('should not list workspaces with --no-workspaces', t => mockWorkspaces(t, [], {
16351cb0ef41Sopenharmony_ci      depth: 0,
16361cb0ef41Sopenharmony_ci      color: 'always',
16371cb0ef41Sopenharmony_ci      workspaces: false,
16381cb0ef41Sopenharmony_ci    }))
16391cb0ef41Sopenharmony_ci
16401cb0ef41Sopenharmony_ci    // --all
16411cb0ef41Sopenharmony_ci    t.test('should list --all workspaces properly', t => mockWorkspaces(t))
16421cb0ef41Sopenharmony_ci
16431cb0ef41Sopenharmony_ci    // --production
16441cb0ef41Sopenharmony_ci    t.test('should list only prod deps of workspaces', t => mockWorkspaces(t, [], {
16451cb0ef41Sopenharmony_ci      omit: ['dev', 'peer', 'optional'],
16461cb0ef41Sopenharmony_ci    }))
16471cb0ef41Sopenharmony_ci
16481cb0ef41Sopenharmony_ci    // filter out a single workspace using args
16491cb0ef41Sopenharmony_ci    t.test('should filter single workspace', t => mockWorkspaces(t, ['d']))
16501cb0ef41Sopenharmony_ci
16511cb0ef41Sopenharmony_ci    // filter out a single workspace and its deps using workspaces filters
16521cb0ef41Sopenharmony_ci    t.test('should filter using workspace config', t => mockWorkspaces(t, [], {
16531cb0ef41Sopenharmony_ci      workspace: 'a',
16541cb0ef41Sopenharmony_ci    }))
16551cb0ef41Sopenharmony_ci
16561cb0ef41Sopenharmony_ci    // filter out a single workspace and include root
16571cb0ef41Sopenharmony_ci    t.test('should inlude root and specified workspace', t => mockWorkspaces(t, [], {
16581cb0ef41Sopenharmony_ci      'include-workspace-root': true,
16591cb0ef41Sopenharmony_ci      workspace: 'd',
16601cb0ef41Sopenharmony_ci    }))
16611cb0ef41Sopenharmony_ci
16621cb0ef41Sopenharmony_ci    // filter out a workspace by parent path
16631cb0ef41Sopenharmony_ci    t.test('should filter by parent folder workspace config', t => mockWorkspaces(t, [], {
16641cb0ef41Sopenharmony_ci      workspace: './group',
16651cb0ef41Sopenharmony_ci    }))
16661cb0ef41Sopenharmony_ci
16671cb0ef41Sopenharmony_ci    // filter by a dep within a workspaces sub tree
16681cb0ef41Sopenharmony_ci    t.test('should print all tree and filter by dep within only the ws subtree', t =>
16691cb0ef41Sopenharmony_ci      mockWorkspaces(t, ['bar'], {
16701cb0ef41Sopenharmony_ci        workspace: 'd',
16711cb0ef41Sopenharmony_ci      }))
16721cb0ef41Sopenharmony_ci  })
16731cb0ef41Sopenharmony_ci
16741cb0ef41Sopenharmony_ci  t.test('filter pkg arg using depth option', async t => {
16751cb0ef41Sopenharmony_ci    const mock = async (t, exec, depth = 0) => {
16761cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
16771cb0ef41Sopenharmony_ci        config: typeof depth === 'number' ? { depth } : {},
16781cb0ef41Sopenharmony_ci        prefixDir: {
16791cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
16801cb0ef41Sopenharmony_ci            name: 'test-pkg-arg-filter-with-depth-opt',
16811cb0ef41Sopenharmony_ci            version: '1.0.0',
16821cb0ef41Sopenharmony_ci            dependencies: {
16831cb0ef41Sopenharmony_ci              a: '^1.0.0',
16841cb0ef41Sopenharmony_ci              b: '^1.0.0',
16851cb0ef41Sopenharmony_ci            },
16861cb0ef41Sopenharmony_ci          }),
16871cb0ef41Sopenharmony_ci          node_modules: {
16881cb0ef41Sopenharmony_ci            a: {
16891cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
16901cb0ef41Sopenharmony_ci                name: 'a',
16911cb0ef41Sopenharmony_ci                version: '1.0.0',
16921cb0ef41Sopenharmony_ci              }),
16931cb0ef41Sopenharmony_ci            },
16941cb0ef41Sopenharmony_ci            b: {
16951cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
16961cb0ef41Sopenharmony_ci                name: 'b',
16971cb0ef41Sopenharmony_ci                version: '1.0.0',
16981cb0ef41Sopenharmony_ci                dependencies: {
16991cb0ef41Sopenharmony_ci                  c: '^1.0.0',
17001cb0ef41Sopenharmony_ci                },
17011cb0ef41Sopenharmony_ci              }),
17021cb0ef41Sopenharmony_ci            },
17031cb0ef41Sopenharmony_ci            c: {
17041cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
17051cb0ef41Sopenharmony_ci                name: 'c',
17061cb0ef41Sopenharmony_ci                version: '1.0.0',
17071cb0ef41Sopenharmony_ci                dependencies: {
17081cb0ef41Sopenharmony_ci                  d: '^1.0.0',
17091cb0ef41Sopenharmony_ci                },
17101cb0ef41Sopenharmony_ci              }),
17111cb0ef41Sopenharmony_ci            },
17121cb0ef41Sopenharmony_ci            d: {
17131cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
17141cb0ef41Sopenharmony_ci                name: 'd',
17151cb0ef41Sopenharmony_ci                version: '1.0.0',
17161cb0ef41Sopenharmony_ci                dependencies: {
17171cb0ef41Sopenharmony_ci                  a: '^1.0.0',
17181cb0ef41Sopenharmony_ci                },
17191cb0ef41Sopenharmony_ci              }),
17201cb0ef41Sopenharmony_ci            },
17211cb0ef41Sopenharmony_ci          },
17221cb0ef41Sopenharmony_ci        },
17231cb0ef41Sopenharmony_ci      })
17241cb0ef41Sopenharmony_ci
17251cb0ef41Sopenharmony_ci      await ls.exec(exec)
17261cb0ef41Sopenharmony_ci
17271cb0ef41Sopenharmony_ci      t.matchSnapshot(cleanCwd(result(), t), 'output')
17281cb0ef41Sopenharmony_ci    }
17291cb0ef41Sopenharmony_ci
17301cb0ef41Sopenharmony_ci    t.test('should list a in top-level only', t => mock(t, ['a']))
17311cb0ef41Sopenharmony_ci
17321cb0ef41Sopenharmony_ci    t.test('should print empty results msg', t => mock(t, ['d']))
17331cb0ef41Sopenharmony_ci
17341cb0ef41Sopenharmony_ci    // if no --depth config is defined, should print path to dep
17351cb0ef41Sopenharmony_ci    t.test('should print expected result', t => mock(t, ['d'], null))
17361cb0ef41Sopenharmony_ci  })
17371cb0ef41Sopenharmony_ci})
17381cb0ef41Sopenharmony_ci
17391cb0ef41Sopenharmony_cit.test('ls --parseable', async t => {
17401cb0ef41Sopenharmony_ci  const parseable = { parseable: true }
17411cb0ef41Sopenharmony_ci  t.test('no args', async t => {
17421cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
17431cb0ef41Sopenharmony_ci      config: parseable,
17441cb0ef41Sopenharmony_ci      prefixDir: {
17451cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
17461cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
17471cb0ef41Sopenharmony_ci          version: '1.0.0',
17481cb0ef41Sopenharmony_ci          dependencies: {
17491cb0ef41Sopenharmony_ci            foo: '^1.0.0',
17501cb0ef41Sopenharmony_ci            chai: '^1.0.0',
17511cb0ef41Sopenharmony_ci          },
17521cb0ef41Sopenharmony_ci        }),
17531cb0ef41Sopenharmony_ci        ...simpleNmFixture,
17541cb0ef41Sopenharmony_ci      },
17551cb0ef41Sopenharmony_ci    })
17561cb0ef41Sopenharmony_ci    await ls.exec([])
17571cb0ef41Sopenharmony_ci    t.matchSnapshot(
17581cb0ef41Sopenharmony_ci      cleanCwd(result()),
17591cb0ef41Sopenharmony_ci      'should output parseable representation of dependencies structure'
17601cb0ef41Sopenharmony_ci    )
17611cb0ef41Sopenharmony_ci  })
17621cb0ef41Sopenharmony_ci
17631cb0ef41Sopenharmony_ci  t.test('missing package.json', async t => {
17641cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
17651cb0ef41Sopenharmony_ci      config: parseable,
17661cb0ef41Sopenharmony_ci      prefixDir: {
17671cb0ef41Sopenharmony_ci        ...simpleNmFixture,
17681cb0ef41Sopenharmony_ci      },
17691cb0ef41Sopenharmony_ci    })
17701cb0ef41Sopenharmony_ci    await ls.exec([])
17711cb0ef41Sopenharmony_ci    t.matchSnapshot(
17721cb0ef41Sopenharmony_ci      cleanCwd(result()),
17731cb0ef41Sopenharmony_ci      'should output parseable missing name/version of top-level package'
17741cb0ef41Sopenharmony_ci    )
17751cb0ef41Sopenharmony_ci  })
17761cb0ef41Sopenharmony_ci
17771cb0ef41Sopenharmony_ci  t.test('extraneous deps', async t => {
17781cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
17791cb0ef41Sopenharmony_ci      config: parseable,
17801cb0ef41Sopenharmony_ci      prefixDir: {
17811cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
17821cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
17831cb0ef41Sopenharmony_ci          version: '1.0.0',
17841cb0ef41Sopenharmony_ci          dependencies: {
17851cb0ef41Sopenharmony_ci            foo: '^1.0.0',
17861cb0ef41Sopenharmony_ci          },
17871cb0ef41Sopenharmony_ci        }),
17881cb0ef41Sopenharmony_ci        ...simpleNmFixture,
17891cb0ef41Sopenharmony_ci      },
17901cb0ef41Sopenharmony_ci    })
17911cb0ef41Sopenharmony_ci    await ls.exec([])
17921cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output containing problems info')
17931cb0ef41Sopenharmony_ci  })
17941cb0ef41Sopenharmony_ci
17951cb0ef41Sopenharmony_ci  t.test('overridden dep', async t => {
17961cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
17971cb0ef41Sopenharmony_ci      config: { ...parseable, long: true },
17981cb0ef41Sopenharmony_ci      prefixDir: {
17991cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
18001cb0ef41Sopenharmony_ci          name: 'test-overridden',
18011cb0ef41Sopenharmony_ci          version: '1.0.0',
18021cb0ef41Sopenharmony_ci          dependencies: {
18031cb0ef41Sopenharmony_ci            foo: '^1.0.0',
18041cb0ef41Sopenharmony_ci          },
18051cb0ef41Sopenharmony_ci          overrides: {
18061cb0ef41Sopenharmony_ci            bar: '1.0.0',
18071cb0ef41Sopenharmony_ci          },
18081cb0ef41Sopenharmony_ci        }),
18091cb0ef41Sopenharmony_ci        node_modules: {
18101cb0ef41Sopenharmony_ci          foo: {
18111cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
18121cb0ef41Sopenharmony_ci              name: 'foo',
18131cb0ef41Sopenharmony_ci              version: '1.0.0',
18141cb0ef41Sopenharmony_ci              dependencies: {
18151cb0ef41Sopenharmony_ci                bar: '^2.0.0',
18161cb0ef41Sopenharmony_ci              },
18171cb0ef41Sopenharmony_ci            }),
18181cb0ef41Sopenharmony_ci          },
18191cb0ef41Sopenharmony_ci          bar: {
18201cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
18211cb0ef41Sopenharmony_ci              name: 'bar',
18221cb0ef41Sopenharmony_ci              version: '1.0.0',
18231cb0ef41Sopenharmony_ci            }),
18241cb0ef41Sopenharmony_ci          },
18251cb0ef41Sopenharmony_ci        },
18261cb0ef41Sopenharmony_ci      },
18271cb0ef41Sopenharmony_ci    })
18281cb0ef41Sopenharmony_ci
18291cb0ef41Sopenharmony_ci    await ls.exec([])
18301cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should contain overridden outout')
18311cb0ef41Sopenharmony_ci  })
18321cb0ef41Sopenharmony_ci
18331cb0ef41Sopenharmony_ci  t.test('with filter arg', async t => {
18341cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
18351cb0ef41Sopenharmony_ci      config: parseable,
18361cb0ef41Sopenharmony_ci      prefixDir: {
18371cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
18381cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
18391cb0ef41Sopenharmony_ci          version: '1.0.0',
18401cb0ef41Sopenharmony_ci          dependencies: {
18411cb0ef41Sopenharmony_ci            foo: '^1.0.0',
18421cb0ef41Sopenharmony_ci            chai: '^1.0.0',
18431cb0ef41Sopenharmony_ci          },
18441cb0ef41Sopenharmony_ci        }),
18451cb0ef41Sopenharmony_ci        ...simpleNmFixture,
18461cb0ef41Sopenharmony_ci      },
18471cb0ef41Sopenharmony_ci    })
18481cb0ef41Sopenharmony_ci    await ls.exec(['chai'])
18491cb0ef41Sopenharmony_ci    t.matchSnapshot(
18501cb0ef41Sopenharmony_ci      cleanCwd(result()),
18511cb0ef41Sopenharmony_ci      'should output parseable contaning only occurrences of filtered by package'
18521cb0ef41Sopenharmony_ci    )
18531cb0ef41Sopenharmony_ci  })
18541cb0ef41Sopenharmony_ci
18551cb0ef41Sopenharmony_ci  t.test('with filter arg nested dep', async t => {
18561cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
18571cb0ef41Sopenharmony_ci      config: parseable,
18581cb0ef41Sopenharmony_ci      prefixDir: {
18591cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
18601cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
18611cb0ef41Sopenharmony_ci          version: '1.0.0',
18621cb0ef41Sopenharmony_ci          dependencies: {
18631cb0ef41Sopenharmony_ci            foo: '^1.0.0',
18641cb0ef41Sopenharmony_ci            chai: '^1.0.0',
18651cb0ef41Sopenharmony_ci          },
18661cb0ef41Sopenharmony_ci        }),
18671cb0ef41Sopenharmony_ci        ...simpleNmFixture,
18681cb0ef41Sopenharmony_ci      },
18691cb0ef41Sopenharmony_ci    })
18701cb0ef41Sopenharmony_ci    await ls.exec(['dog'])
18711cb0ef41Sopenharmony_ci    t.matchSnapshot(
18721cb0ef41Sopenharmony_ci      cleanCwd(result()),
18731cb0ef41Sopenharmony_ci      'should output parseable contaning only occurrences of filtered package'
18741cb0ef41Sopenharmony_ci    )
18751cb0ef41Sopenharmony_ci  })
18761cb0ef41Sopenharmony_ci
18771cb0ef41Sopenharmony_ci  t.test('with multiple filter args', async t => {
18781cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
18791cb0ef41Sopenharmony_ci      config: parseable,
18801cb0ef41Sopenharmony_ci      prefixDir: {
18811cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
18821cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
18831cb0ef41Sopenharmony_ci          version: '1.0.0',
18841cb0ef41Sopenharmony_ci          dependencies: {
18851cb0ef41Sopenharmony_ci            foo: '^1.0.0',
18861cb0ef41Sopenharmony_ci            chai: '^1.0.0',
18871cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
18881cb0ef41Sopenharmony_ci          },
18891cb0ef41Sopenharmony_ci        }),
18901cb0ef41Sopenharmony_ci        node_modules: {
18911cb0ef41Sopenharmony_ci          ...simpleNmFixture.node_modules,
18921cb0ef41Sopenharmony_ci          ipsum: {
18931cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
18941cb0ef41Sopenharmony_ci              name: 'ipsum',
18951cb0ef41Sopenharmony_ci              version: '1.0.0',
18961cb0ef41Sopenharmony_ci            }),
18971cb0ef41Sopenharmony_ci          },
18981cb0ef41Sopenharmony_ci        },
18991cb0ef41Sopenharmony_ci      },
19001cb0ef41Sopenharmony_ci    })
19011cb0ef41Sopenharmony_ci    await ls.exec(['dog@*', 'chai@1.0.0'])
19021cb0ef41Sopenharmony_ci    t.matchSnapshot(
19031cb0ef41Sopenharmony_ci      cleanCwd(result()),
19041cb0ef41Sopenharmony_ci      /* eslint-disable-next-line max-len */
19051cb0ef41Sopenharmony_ci      'should output parseable contaning only occurrences of multiple filtered packages and their ancestors'
19061cb0ef41Sopenharmony_ci    )
19071cb0ef41Sopenharmony_ci  })
19081cb0ef41Sopenharmony_ci
19091cb0ef41Sopenharmony_ci  t.test('with missing filter arg', async t => {
19101cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
19111cb0ef41Sopenharmony_ci      config: parseable,
19121cb0ef41Sopenharmony_ci      prefixDir: {
19131cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
19141cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
19151cb0ef41Sopenharmony_ci          version: '1.0.0',
19161cb0ef41Sopenharmony_ci          dependencies: {
19171cb0ef41Sopenharmony_ci            foo: '^1.0.0',
19181cb0ef41Sopenharmony_ci            chai: '^1.0.0',
19191cb0ef41Sopenharmony_ci          },
19201cb0ef41Sopenharmony_ci        }),
19211cb0ef41Sopenharmony_ci        ...simpleNmFixture,
19221cb0ef41Sopenharmony_ci      },
19231cb0ef41Sopenharmony_ci    })
19241cb0ef41Sopenharmony_ci    await ls.exec(['notadep'])
19251cb0ef41Sopenharmony_ci    t.matchSnapshot(
19261cb0ef41Sopenharmony_ci      cleanCwd(result()),
19271cb0ef41Sopenharmony_ci      'should output parseable output containing no dependencies info'
19281cb0ef41Sopenharmony_ci    )
19291cb0ef41Sopenharmony_ci  })
19301cb0ef41Sopenharmony_ci
19311cb0ef41Sopenharmony_ci  t.test('default --depth value should be 0', async t => {
19321cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
19331cb0ef41Sopenharmony_ci      config: { ...parseable, all: false },
19341cb0ef41Sopenharmony_ci      prefixDir: {
19351cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
19361cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
19371cb0ef41Sopenharmony_ci          version: '1.0.0',
19381cb0ef41Sopenharmony_ci          dependencies: {
19391cb0ef41Sopenharmony_ci            foo: '^1.0.0',
19401cb0ef41Sopenharmony_ci            chai: '^1.0.0',
19411cb0ef41Sopenharmony_ci          },
19421cb0ef41Sopenharmony_ci        }),
19431cb0ef41Sopenharmony_ci        ...simpleNmFixture,
19441cb0ef41Sopenharmony_ci      },
19451cb0ef41Sopenharmony_ci    })
19461cb0ef41Sopenharmony_ci    await ls.exec([])
19471cb0ef41Sopenharmony_ci    t.matchSnapshot(
19481cb0ef41Sopenharmony_ci      cleanCwd(result()),
19491cb0ef41Sopenharmony_ci      'should output parseable output containing only top-level dependencies'
19501cb0ef41Sopenharmony_ci    )
19511cb0ef41Sopenharmony_ci  })
19521cb0ef41Sopenharmony_ci
19531cb0ef41Sopenharmony_ci  t.test('--depth=0', async t => {
19541cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
19551cb0ef41Sopenharmony_ci      config: { ...parseable, all: false, depth: 0 },
19561cb0ef41Sopenharmony_ci      prefixDir: {
19571cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
19581cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
19591cb0ef41Sopenharmony_ci          version: '1.0.0',
19601cb0ef41Sopenharmony_ci          dependencies: {
19611cb0ef41Sopenharmony_ci            foo: '^1.0.0',
19621cb0ef41Sopenharmony_ci            chai: '^1.0.0',
19631cb0ef41Sopenharmony_ci          },
19641cb0ef41Sopenharmony_ci        }),
19651cb0ef41Sopenharmony_ci        ...simpleNmFixture,
19661cb0ef41Sopenharmony_ci      },
19671cb0ef41Sopenharmony_ci    })
19681cb0ef41Sopenharmony_ci    await ls.exec([])
19691cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()),
19701cb0ef41Sopenharmony_ci      'should output tree containing only top-level dependencies')
19711cb0ef41Sopenharmony_ci  })
19721cb0ef41Sopenharmony_ci
19731cb0ef41Sopenharmony_ci  t.test('--depth=1', async t => {
19741cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
19751cb0ef41Sopenharmony_ci      config: { ...parseable, all: false, depth: 1 },
19761cb0ef41Sopenharmony_ci      prefixDir: {
19771cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
19781cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
19791cb0ef41Sopenharmony_ci          version: '1.0.0',
19801cb0ef41Sopenharmony_ci          dependencies: {
19811cb0ef41Sopenharmony_ci            foo: '^1.0.0',
19821cb0ef41Sopenharmony_ci            chai: '^1.0.0',
19831cb0ef41Sopenharmony_ci          },
19841cb0ef41Sopenharmony_ci        }),
19851cb0ef41Sopenharmony_ci        ...simpleNmFixture,
19861cb0ef41Sopenharmony_ci      },
19871cb0ef41Sopenharmony_ci    })
19881cb0ef41Sopenharmony_ci    await ls.exec([])
19891cb0ef41Sopenharmony_ci    t.matchSnapshot(
19901cb0ef41Sopenharmony_ci      cleanCwd(result()),
19911cb0ef41Sopenharmony_ci      'should output parseable containing top-level deps and their deps only'
19921cb0ef41Sopenharmony_ci    )
19931cb0ef41Sopenharmony_ci  })
19941cb0ef41Sopenharmony_ci
19951cb0ef41Sopenharmony_ci  t.test('missing/invalid/extraneous', async t => {
19961cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
19971cb0ef41Sopenharmony_ci      config: parseable,
19981cb0ef41Sopenharmony_ci      prefixDir: {
19991cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
20001cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
20011cb0ef41Sopenharmony_ci          version: '1.0.0',
20021cb0ef41Sopenharmony_ci          dependencies: {
20031cb0ef41Sopenharmony_ci            foo: '^2.0.0',
20041cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
20051cb0ef41Sopenharmony_ci          },
20061cb0ef41Sopenharmony_ci        }),
20071cb0ef41Sopenharmony_ci        ...simpleNmFixture,
20081cb0ef41Sopenharmony_ci      },
20091cb0ef41Sopenharmony_ci    })
20101cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' }, 'should list dep problems')
20111cb0ef41Sopenharmony_ci    t.matchSnapshot(
20121cb0ef41Sopenharmony_ci      cleanCwd(result()),
20131cb0ef41Sopenharmony_ci      'should output parseable containing top-level deps and their deps only'
20141cb0ef41Sopenharmony_ci    )
20151cb0ef41Sopenharmony_ci  })
20161cb0ef41Sopenharmony_ci
20171cb0ef41Sopenharmony_ci  t.test('--dev', async t => {
20181cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
20191cb0ef41Sopenharmony_ci      config: {
20201cb0ef41Sopenharmony_ci        ...parseable,
20211cb0ef41Sopenharmony_ci        omit: ['peer', 'prod', 'optional'],
20221cb0ef41Sopenharmony_ci      },
20231cb0ef41Sopenharmony_ci      prefixDir: {
20241cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
20251cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
20261cb0ef41Sopenharmony_ci          version: '1.0.0',
20271cb0ef41Sopenharmony_ci          dependencies: {
20281cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
20291cb0ef41Sopenharmony_ci            chai: '^1.0.0',
20301cb0ef41Sopenharmony_ci          },
20311cb0ef41Sopenharmony_ci          devDependencies: {
20321cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
20331cb0ef41Sopenharmony_ci          },
20341cb0ef41Sopenharmony_ci          optionalDependencies: {
20351cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
20361cb0ef41Sopenharmony_ci          },
20371cb0ef41Sopenharmony_ci          peerDependencies: {
20381cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
20391cb0ef41Sopenharmony_ci          },
20401cb0ef41Sopenharmony_ci        }),
20411cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
20421cb0ef41Sopenharmony_ci      },
20431cb0ef41Sopenharmony_ci    })
20441cb0ef41Sopenharmony_ci    await ls.exec([])
20451cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing dev deps')
20461cb0ef41Sopenharmony_ci  })
20471cb0ef41Sopenharmony_ci
20481cb0ef41Sopenharmony_ci  t.test('--link', async t => {
20491cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
20501cb0ef41Sopenharmony_ci      config: {
20511cb0ef41Sopenharmony_ci        ...parseable,
20521cb0ef41Sopenharmony_ci        link: true,
20531cb0ef41Sopenharmony_ci      },
20541cb0ef41Sopenharmony_ci      prefixDir: {
20551cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
20561cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
20571cb0ef41Sopenharmony_ci          version: '1.0.0',
20581cb0ef41Sopenharmony_ci          dependencies: {
20591cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
20601cb0ef41Sopenharmony_ci            chai: '^1.0.0',
20611cb0ef41Sopenharmony_ci            'linked-dep': '^1.0.0',
20621cb0ef41Sopenharmony_ci          },
20631cb0ef41Sopenharmony_ci          devDependencies: {
20641cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
20651cb0ef41Sopenharmony_ci          },
20661cb0ef41Sopenharmony_ci          optionalDependencies: {
20671cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
20681cb0ef41Sopenharmony_ci          },
20691cb0ef41Sopenharmony_ci          peerDependencies: {
20701cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
20711cb0ef41Sopenharmony_ci          },
20721cb0ef41Sopenharmony_ci        }),
20731cb0ef41Sopenharmony_ci        'linked-dep': {
20741cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
20751cb0ef41Sopenharmony_ci            name: 'linked-dep',
20761cb0ef41Sopenharmony_ci            version: '1.0.0',
20771cb0ef41Sopenharmony_ci          }),
20781cb0ef41Sopenharmony_ci        },
20791cb0ef41Sopenharmony_ci        node_modules: {
20801cb0ef41Sopenharmony_ci          'linked-dep': t.fixture('symlink', '../linked-dep'),
20811cb0ef41Sopenharmony_ci          ...diffDepTypesNmFixture.node_modules,
20821cb0ef41Sopenharmony_ci        },
20831cb0ef41Sopenharmony_ci      },
20841cb0ef41Sopenharmony_ci    })
20851cb0ef41Sopenharmony_ci    await ls.exec([])
20861cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing linked deps')
20871cb0ef41Sopenharmony_ci  })
20881cb0ef41Sopenharmony_ci
20891cb0ef41Sopenharmony_ci  t.test('--production', async t => {
20901cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
20911cb0ef41Sopenharmony_ci      config: {
20921cb0ef41Sopenharmony_ci        ...parseable,
20931cb0ef41Sopenharmony_ci        omit: ['dev', 'peer'],
20941cb0ef41Sopenharmony_ci      },
20951cb0ef41Sopenharmony_ci      prefixDir: {
20961cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
20971cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
20981cb0ef41Sopenharmony_ci          version: '1.0.0',
20991cb0ef41Sopenharmony_ci          dependencies: {
21001cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
21011cb0ef41Sopenharmony_ci            chai: '^1.0.0',
21021cb0ef41Sopenharmony_ci          },
21031cb0ef41Sopenharmony_ci          devDependencies: {
21041cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
21051cb0ef41Sopenharmony_ci          },
21061cb0ef41Sopenharmony_ci          optionalDependencies: {
21071cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
21081cb0ef41Sopenharmony_ci          },
21091cb0ef41Sopenharmony_ci          peerDependencies: {
21101cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
21111cb0ef41Sopenharmony_ci          },
21121cb0ef41Sopenharmony_ci        }),
21131cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
21141cb0ef41Sopenharmony_ci      },
21151cb0ef41Sopenharmony_ci    })
21161cb0ef41Sopenharmony_ci    await ls.exec([])
21171cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing production deps')
21181cb0ef41Sopenharmony_ci  })
21191cb0ef41Sopenharmony_ci
21201cb0ef41Sopenharmony_ci  t.test('--long', async t => {
21211cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
21221cb0ef41Sopenharmony_ci      config: {
21231cb0ef41Sopenharmony_ci        ...parseable,
21241cb0ef41Sopenharmony_ci        long: true,
21251cb0ef41Sopenharmony_ci      },
21261cb0ef41Sopenharmony_ci      prefixDir: {
21271cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
21281cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
21291cb0ef41Sopenharmony_ci          version: '1.0.0',
21301cb0ef41Sopenharmony_ci          dependencies: {
21311cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
21321cb0ef41Sopenharmony_ci            chai: '^1.0.0',
21331cb0ef41Sopenharmony_ci          },
21341cb0ef41Sopenharmony_ci          devDependencies: {
21351cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
21361cb0ef41Sopenharmony_ci          },
21371cb0ef41Sopenharmony_ci          optionalDependencies: {
21381cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
21391cb0ef41Sopenharmony_ci          },
21401cb0ef41Sopenharmony_ci          peerDependencies: {
21411cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
21421cb0ef41Sopenharmony_ci          },
21431cb0ef41Sopenharmony_ci        }),
21441cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
21451cb0ef41Sopenharmony_ci      },
21461cb0ef41Sopenharmony_ci    })
21471cb0ef41Sopenharmony_ci    await ls.exec([])
21481cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree info with descriptions')
21491cb0ef41Sopenharmony_ci  })
21501cb0ef41Sopenharmony_ci
21511cb0ef41Sopenharmony_ci  t.test('--long with extraneous deps', async t => {
21521cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
21531cb0ef41Sopenharmony_ci      config: {
21541cb0ef41Sopenharmony_ci        ...parseable,
21551cb0ef41Sopenharmony_ci        long: true,
21561cb0ef41Sopenharmony_ci      },
21571cb0ef41Sopenharmony_ci      prefixDir: {
21581cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
21591cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
21601cb0ef41Sopenharmony_ci          version: '1.0.0',
21611cb0ef41Sopenharmony_ci          dependencies: {
21621cb0ef41Sopenharmony_ci            foo: '^1.0.0',
21631cb0ef41Sopenharmony_ci          },
21641cb0ef41Sopenharmony_ci        }),
21651cb0ef41Sopenharmony_ci        ...simpleNmFixture,
21661cb0ef41Sopenharmony_ci      },
21671cb0ef41Sopenharmony_ci    })
21681cb0ef41Sopenharmony_ci    await ls.exec([])
21691cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output long parseable output with extraneous info')
21701cb0ef41Sopenharmony_ci  })
21711cb0ef41Sopenharmony_ci
21721cb0ef41Sopenharmony_ci  t.test('--long missing/invalid/extraneous', async t => {
21731cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
21741cb0ef41Sopenharmony_ci      config: {
21751cb0ef41Sopenharmony_ci        ...parseable,
21761cb0ef41Sopenharmony_ci        long: true,
21771cb0ef41Sopenharmony_ci      },
21781cb0ef41Sopenharmony_ci      prefixDir: {
21791cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
21801cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
21811cb0ef41Sopenharmony_ci          version: '1.0.0',
21821cb0ef41Sopenharmony_ci          dependencies: {
21831cb0ef41Sopenharmony_ci            foo: '^2.0.0',
21841cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
21851cb0ef41Sopenharmony_ci          },
21861cb0ef41Sopenharmony_ci        }),
21871cb0ef41Sopenharmony_ci        ...simpleNmFixture,
21881cb0ef41Sopenharmony_ci      },
21891cb0ef41Sopenharmony_ci    })
21901cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' }, 'should list dep problems')
21911cb0ef41Sopenharmony_ci    t.matchSnapshot(
21921cb0ef41Sopenharmony_ci      cleanCwd(result()),
21931cb0ef41Sopenharmony_ci      'should output parseable result containing EXTRANEOUS/INVALID labels'
21941cb0ef41Sopenharmony_ci    )
21951cb0ef41Sopenharmony_ci  })
21961cb0ef41Sopenharmony_ci
21971cb0ef41Sopenharmony_ci  t.test('--long print symlink target location', async t => {
21981cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
21991cb0ef41Sopenharmony_ci      config: {
22001cb0ef41Sopenharmony_ci        ...parseable,
22011cb0ef41Sopenharmony_ci        long: true,
22021cb0ef41Sopenharmony_ci      },
22031cb0ef41Sopenharmony_ci      prefixDir: {
22041cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
22051cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
22061cb0ef41Sopenharmony_ci          version: '1.0.0',
22071cb0ef41Sopenharmony_ci          dependencies: {
22081cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
22091cb0ef41Sopenharmony_ci            chai: '^1.0.0',
22101cb0ef41Sopenharmony_ci            'linked-dep': '^1.0.0',
22111cb0ef41Sopenharmony_ci          },
22121cb0ef41Sopenharmony_ci          devDependencies: {
22131cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
22141cb0ef41Sopenharmony_ci          },
22151cb0ef41Sopenharmony_ci          optionalDependencies: {
22161cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
22171cb0ef41Sopenharmony_ci          },
22181cb0ef41Sopenharmony_ci          peerDependencies: {
22191cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
22201cb0ef41Sopenharmony_ci          },
22211cb0ef41Sopenharmony_ci        }),
22221cb0ef41Sopenharmony_ci        'linked-dep': {
22231cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
22241cb0ef41Sopenharmony_ci            name: 'linked-dep',
22251cb0ef41Sopenharmony_ci            version: '1.0.0',
22261cb0ef41Sopenharmony_ci          }),
22271cb0ef41Sopenharmony_ci        },
22281cb0ef41Sopenharmony_ci        node_modules: {
22291cb0ef41Sopenharmony_ci          'linked-dep': t.fixture('symlink', '../linked-dep'),
22301cb0ef41Sopenharmony_ci          ...diffDepTypesNmFixture.node_modules,
22311cb0ef41Sopenharmony_ci        },
22321cb0ef41Sopenharmony_ci      },
22331cb0ef41Sopenharmony_ci    })
22341cb0ef41Sopenharmony_ci    await ls.exec([])
22351cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output parseable results with symlink targets')
22361cb0ef41Sopenharmony_ci  })
22371cb0ef41Sopenharmony_ci
22381cb0ef41Sopenharmony_ci  t.test('--long --depth=0', async t => {
22391cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
22401cb0ef41Sopenharmony_ci      config: {
22411cb0ef41Sopenharmony_ci        ...parseable,
22421cb0ef41Sopenharmony_ci        all: false,
22431cb0ef41Sopenharmony_ci        depth: 0,
22441cb0ef41Sopenharmony_ci        long: true,
22451cb0ef41Sopenharmony_ci      },
22461cb0ef41Sopenharmony_ci      prefixDir: {
22471cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
22481cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
22491cb0ef41Sopenharmony_ci          version: '1.0.0',
22501cb0ef41Sopenharmony_ci          dependencies: {
22511cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
22521cb0ef41Sopenharmony_ci            chai: '^1.0.0',
22531cb0ef41Sopenharmony_ci          },
22541cb0ef41Sopenharmony_ci          devDependencies: {
22551cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
22561cb0ef41Sopenharmony_ci          },
22571cb0ef41Sopenharmony_ci          optionalDependencies: {
22581cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
22591cb0ef41Sopenharmony_ci          },
22601cb0ef41Sopenharmony_ci          peerDependencies: {
22611cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
22621cb0ef41Sopenharmony_ci          },
22631cb0ef41Sopenharmony_ci        }),
22641cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
22651cb0ef41Sopenharmony_ci      },
22661cb0ef41Sopenharmony_ci    })
22671cb0ef41Sopenharmony_ci    await ls.exec([])
22681cb0ef41Sopenharmony_ci    t.matchSnapshot(
22691cb0ef41Sopenharmony_ci      cleanCwd(result()),
22701cb0ef41Sopenharmony_ci      'should output tree containing top-level deps with descriptions'
22711cb0ef41Sopenharmony_ci    )
22721cb0ef41Sopenharmony_ci  })
22731cb0ef41Sopenharmony_ci
22741cb0ef41Sopenharmony_ci  t.test('json read problems', async t => {
22751cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
22761cb0ef41Sopenharmony_ci      config: {
22771cb0ef41Sopenharmony_ci        ...parseable,
22781cb0ef41Sopenharmony_ci      },
22791cb0ef41Sopenharmony_ci      prefixDir: {
22801cb0ef41Sopenharmony_ci        'package.json': '{broken json',
22811cb0ef41Sopenharmony_ci      },
22821cb0ef41Sopenharmony_ci    })
22831cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'EJSONPARSE' }, 'should throw EJSONPARSE error')
22841cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print empty result')
22851cb0ef41Sopenharmony_ci  })
22861cb0ef41Sopenharmony_ci
22871cb0ef41Sopenharmony_ci  t.test('empty location', async t => {
22881cb0ef41Sopenharmony_ci    const { ls, result } = await mockLs(t, {
22891cb0ef41Sopenharmony_ci      config: {
22901cb0ef41Sopenharmony_ci        ...parseable,
22911cb0ef41Sopenharmony_ci      },
22921cb0ef41Sopenharmony_ci    })
22931cb0ef41Sopenharmony_ci    await ls.exec([])
22941cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print empty result')
22951cb0ef41Sopenharmony_ci  })
22961cb0ef41Sopenharmony_ci
22971cb0ef41Sopenharmony_ci  t.test('unmet peer dep', async t => {
22981cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
22991cb0ef41Sopenharmony_ci      config: {
23001cb0ef41Sopenharmony_ci        ...parseable,
23011cb0ef41Sopenharmony_ci      },
23021cb0ef41Sopenharmony_ci      prefixDir: {
23031cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
23041cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
23051cb0ef41Sopenharmony_ci          version: '1.0.0',
23061cb0ef41Sopenharmony_ci          dependencies: {
23071cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
23081cb0ef41Sopenharmony_ci            chai: '^1.0.0',
23091cb0ef41Sopenharmony_ci          },
23101cb0ef41Sopenharmony_ci          devDependencies: {
23111cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
23121cb0ef41Sopenharmony_ci          },
23131cb0ef41Sopenharmony_ci          optionalDependencies: {
23141cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
23151cb0ef41Sopenharmony_ci          },
23161cb0ef41Sopenharmony_ci          peerDependencies: {
23171cb0ef41Sopenharmony_ci            'peer-dep': '^2.0.0', // mismatching version #
23181cb0ef41Sopenharmony_ci          },
23191cb0ef41Sopenharmony_ci        }),
23201cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
23211cb0ef41Sopenharmony_ci      },
23221cb0ef41Sopenharmony_ci    })
23231cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]))
23241cb0ef41Sopenharmony_ci    t.matchSnapshot(
23251cb0ef41Sopenharmony_ci      cleanCwd(result()),
23261cb0ef41Sopenharmony_ci      'should output parseable signaling missing peer dep in problems'
23271cb0ef41Sopenharmony_ci    )
23281cb0ef41Sopenharmony_ci  })
23291cb0ef41Sopenharmony_ci
23301cb0ef41Sopenharmony_ci  t.test('unmet optional dep', async t => {
23311cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
23321cb0ef41Sopenharmony_ci      config: {
23331cb0ef41Sopenharmony_ci        ...parseable,
23341cb0ef41Sopenharmony_ci      },
23351cb0ef41Sopenharmony_ci      prefixDir: {
23361cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
23371cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
23381cb0ef41Sopenharmony_ci          version: '1.0.0',
23391cb0ef41Sopenharmony_ci          dependencies: {
23401cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
23411cb0ef41Sopenharmony_ci            chai: '^1.0.0',
23421cb0ef41Sopenharmony_ci          },
23431cb0ef41Sopenharmony_ci          devDependencies: {
23441cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
23451cb0ef41Sopenharmony_ci          },
23461cb0ef41Sopenharmony_ci          optionalDependencies: {
23471cb0ef41Sopenharmony_ci            'missing-optional-dep': '^1.0.0',
23481cb0ef41Sopenharmony_ci            'optional-dep': '^2.0.0', // mismatching version #
23491cb0ef41Sopenharmony_ci          },
23501cb0ef41Sopenharmony_ci          peerDependencies: {
23511cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
23521cb0ef41Sopenharmony_ci          },
23531cb0ef41Sopenharmony_ci        }),
23541cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
23551cb0ef41Sopenharmony_ci      },
23561cb0ef41Sopenharmony_ci    })
23571cb0ef41Sopenharmony_ci    await t.rejects(
23581cb0ef41Sopenharmony_ci      ls.exec([]),
23591cb0ef41Sopenharmony_ci      { code: 'ELSPROBLEMS', message: /invalid: optional-dep@1.0.0/ },
23601cb0ef41Sopenharmony_ci      'should have invalid dep error msg'
23611cb0ef41Sopenharmony_ci    )
23621cb0ef41Sopenharmony_ci    t.matchSnapshot(
23631cb0ef41Sopenharmony_ci      cleanCwd(result()),
23641cb0ef41Sopenharmony_ci      'should output parseable with empty entry for missing optional deps'
23651cb0ef41Sopenharmony_ci    )
23661cb0ef41Sopenharmony_ci  })
23671cb0ef41Sopenharmony_ci
23681cb0ef41Sopenharmony_ci  t.test('cycle deps', async t => {
23691cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
23701cb0ef41Sopenharmony_ci      config: {
23711cb0ef41Sopenharmony_ci        ...parseable,
23721cb0ef41Sopenharmony_ci      },
23731cb0ef41Sopenharmony_ci      prefixDir: {
23741cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
23751cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
23761cb0ef41Sopenharmony_ci          version: '1.0.0',
23771cb0ef41Sopenharmony_ci          dependencies: {
23781cb0ef41Sopenharmony_ci            a: '^1.0.0',
23791cb0ef41Sopenharmony_ci          },
23801cb0ef41Sopenharmony_ci        }),
23811cb0ef41Sopenharmony_ci        node_modules: {
23821cb0ef41Sopenharmony_ci          a: {
23831cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
23841cb0ef41Sopenharmony_ci              name: 'a',
23851cb0ef41Sopenharmony_ci              version: '1.0.0',
23861cb0ef41Sopenharmony_ci              dependencies: {
23871cb0ef41Sopenharmony_ci                b: '^1.0.0',
23881cb0ef41Sopenharmony_ci              },
23891cb0ef41Sopenharmony_ci            }),
23901cb0ef41Sopenharmony_ci          },
23911cb0ef41Sopenharmony_ci          b: {
23921cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
23931cb0ef41Sopenharmony_ci              name: 'b',
23941cb0ef41Sopenharmony_ci              version: '1.0.0',
23951cb0ef41Sopenharmony_ci              dependencies: {
23961cb0ef41Sopenharmony_ci                a: '^1.0.0',
23971cb0ef41Sopenharmony_ci              },
23981cb0ef41Sopenharmony_ci            }),
23991cb0ef41Sopenharmony_ci          },
24001cb0ef41Sopenharmony_ci        },
24011cb0ef41Sopenharmony_ci      },
24021cb0ef41Sopenharmony_ci    })
24031cb0ef41Sopenharmony_ci    await ls.exec([])
24041cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print tree output omitting deduped ref')
24051cb0ef41Sopenharmony_ci  })
24061cb0ef41Sopenharmony_ci
24071cb0ef41Sopenharmony_ci  t.test('using aliases', async t => {
24081cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
24091cb0ef41Sopenharmony_ci      config: {
24101cb0ef41Sopenharmony_ci        ...parseable,
24111cb0ef41Sopenharmony_ci      },
24121cb0ef41Sopenharmony_ci      prefixDir: {
24131cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
24141cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
24151cb0ef41Sopenharmony_ci          version: '1.0.0',
24161cb0ef41Sopenharmony_ci          dependencies: {
24171cb0ef41Sopenharmony_ci            a: 'npm:b@1.0.0',
24181cb0ef41Sopenharmony_ci          },
24191cb0ef41Sopenharmony_ci        }),
24201cb0ef41Sopenharmony_ci        node_modules: {
24211cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
24221cb0ef41Sopenharmony_ci            packages: {
24231cb0ef41Sopenharmony_ci              'node_modules/a': {
24241cb0ef41Sopenharmony_ci                name: 'b',
24251cb0ef41Sopenharmony_ci                version: '1.0.0',
24261cb0ef41Sopenharmony_ci                resolved: 'https://localhost:8080/abbrev/-/abbrev-1.1.1.tgz',
24271cb0ef41Sopenharmony_ci              },
24281cb0ef41Sopenharmony_ci            },
24291cb0ef41Sopenharmony_ci          }),
24301cb0ef41Sopenharmony_ci          a: {
24311cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
24321cb0ef41Sopenharmony_ci              name: 'b',
24331cb0ef41Sopenharmony_ci              version: '1.0.0',
24341cb0ef41Sopenharmony_ci              _from: 'a@npm:b',
24351cb0ef41Sopenharmony_ci              _resolved: 'https://localhost:8080/abbrev/-/abbrev-1.1.1.tgz',
24361cb0ef41Sopenharmony_ci              _requested: {
24371cb0ef41Sopenharmony_ci                type: 'alias',
24381cb0ef41Sopenharmony_ci              },
24391cb0ef41Sopenharmony_ci            }),
24401cb0ef41Sopenharmony_ci          },
24411cb0ef41Sopenharmony_ci        },
24421cb0ef41Sopenharmony_ci      },
24431cb0ef41Sopenharmony_ci    })
24441cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
24451cb0ef41Sopenharmony_ci    await ls.exec([])
24461cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing aliases')
24471cb0ef41Sopenharmony_ci  })
24481cb0ef41Sopenharmony_ci
24491cb0ef41Sopenharmony_ci  t.test('resolved points to git ref', async t => {
24501cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
24511cb0ef41Sopenharmony_ci      config: {
24521cb0ef41Sopenharmony_ci        ...parseable,
24531cb0ef41Sopenharmony_ci      },
24541cb0ef41Sopenharmony_ci      prefixDir: {
24551cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
24561cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
24571cb0ef41Sopenharmony_ci          version: '1.0.0',
24581cb0ef41Sopenharmony_ci          dependencies: {
24591cb0ef41Sopenharmony_ci            abbrev: 'git+https://github.com/isaacs/abbrev-js.git',
24601cb0ef41Sopenharmony_ci          },
24611cb0ef41Sopenharmony_ci        }),
24621cb0ef41Sopenharmony_ci        node_modules: {
24631cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
24641cb0ef41Sopenharmony_ci            packages: {
24651cb0ef41Sopenharmony_ci              'node_modules/abbrev': {
24661cb0ef41Sopenharmony_ci                name: 'abbrev',
24671cb0ef41Sopenharmony_ci                version: '1.1.1',
24681cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
24691cb0ef41Sopenharmony_ci                resolved: 'git+https://github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
24701cb0ef41Sopenharmony_ci              },
24711cb0ef41Sopenharmony_ci            },
24721cb0ef41Sopenharmony_ci          }),
24731cb0ef41Sopenharmony_ci          abbrev: {
24741cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
24751cb0ef41Sopenharmony_ci              name: 'abbrev',
24761cb0ef41Sopenharmony_ci              version: '1.1.1',
24771cb0ef41Sopenharmony_ci              _id: 'abbrev@1.1.1',
24781cb0ef41Sopenharmony_ci              _from: 'git+https://github.com/isaacs/abbrev-js.git',
24791cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
24801cb0ef41Sopenharmony_ci              _resolved: 'git+https://github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
24811cb0ef41Sopenharmony_ci              _requested: {
24821cb0ef41Sopenharmony_ci                type: 'git',
24831cb0ef41Sopenharmony_ci                raw: 'git+https:github.com/isaacs/abbrev-js.git',
24841cb0ef41Sopenharmony_ci                rawSpec: 'git+https:github.com/isaacs/abbrev-js.git',
24851cb0ef41Sopenharmony_ci                saveSpec: 'git+https://github.com/isaacs/abbrev-js.git',
24861cb0ef41Sopenharmony_ci                fetchSpec: 'https://github.com/isaacs/abbrev-js.git',
24871cb0ef41Sopenharmony_ci                gitCommittish: null,
24881cb0ef41Sopenharmony_ci              },
24891cb0ef41Sopenharmony_ci            }),
24901cb0ef41Sopenharmony_ci          },
24911cb0ef41Sopenharmony_ci        },
24921cb0ef41Sopenharmony_ci      },
24931cb0ef41Sopenharmony_ci    })
24941cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
24951cb0ef41Sopenharmony_ci    await ls.exec([])
24961cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should output tree containing git refs')
24971cb0ef41Sopenharmony_ci  })
24981cb0ef41Sopenharmony_ci
24991cb0ef41Sopenharmony_ci  t.test('from and resolved properties', async t => {
25001cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
25011cb0ef41Sopenharmony_ci      config: {
25021cb0ef41Sopenharmony_ci        ...parseable,
25031cb0ef41Sopenharmony_ci      },
25041cb0ef41Sopenharmony_ci      prefixDir: {
25051cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
25061cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
25071cb0ef41Sopenharmony_ci          version: '1.0.0',
25081cb0ef41Sopenharmony_ci          dependencies: {
25091cb0ef41Sopenharmony_ci            'simple-output': '^2.0.0',
25101cb0ef41Sopenharmony_ci          },
25111cb0ef41Sopenharmony_ci        }),
25121cb0ef41Sopenharmony_ci        node_modules: {
25131cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
25141cb0ef41Sopenharmony_ci            packages: {
25151cb0ef41Sopenharmony_ci              'node_modules/simple-output': {
25161cb0ef41Sopenharmony_ci                name: 'simple-output',
25171cb0ef41Sopenharmony_ci                version: '2.1.1',
25181cb0ef41Sopenharmony_ci                resolved: 'https://registry.npmjs.org/simple-output/-/simple-output-2.1.1.tgz',
25191cb0ef41Sopenharmony_ci                shasum: '3c07708ec9ef3e3c985cf0ddd67df09ab8ec2abc',
25201cb0ef41Sopenharmony_ci              },
25211cb0ef41Sopenharmony_ci            },
25221cb0ef41Sopenharmony_ci          }),
25231cb0ef41Sopenharmony_ci          'simple-output': {
25241cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
25251cb0ef41Sopenharmony_ci              name: 'simple-output',
25261cb0ef41Sopenharmony_ci              version: '2.1.1',
25271cb0ef41Sopenharmony_ci              _from: 'simple-output',
25281cb0ef41Sopenharmony_ci              _id: 'simple-output@2.1.1',
25291cb0ef41Sopenharmony_ci              _resolved: 'https://registry.npmjs.org/simple-output/-/simple-output-2.1.1.tgz',
25301cb0ef41Sopenharmony_ci              _requested: {
25311cb0ef41Sopenharmony_ci                type: 'tag',
25321cb0ef41Sopenharmony_ci                registry: true,
25331cb0ef41Sopenharmony_ci                raw: 'simple-output',
25341cb0ef41Sopenharmony_ci                name: 'simple-output',
25351cb0ef41Sopenharmony_ci                escapedName: 'simple-output',
25361cb0ef41Sopenharmony_ci                rawSpec: '',
25371cb0ef41Sopenharmony_ci                saveSpec: null,
25381cb0ef41Sopenharmony_ci                fetchSpec: 'latest',
25391cb0ef41Sopenharmony_ci              },
25401cb0ef41Sopenharmony_ci              _requiredBy: ['#USER', '/'],
25411cb0ef41Sopenharmony_ci              _shasum: '3c07708ec9ef3e3c985cf0ddd67df09ab8ec2abc',
25421cb0ef41Sopenharmony_ci              _spec: 'simple-output',
25431cb0ef41Sopenharmony_ci            }),
25441cb0ef41Sopenharmony_ci          },
25451cb0ef41Sopenharmony_ci        },
25461cb0ef41Sopenharmony_ci      },
25471cb0ef41Sopenharmony_ci    })
25481cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
25491cb0ef41Sopenharmony_ci    await ls.exec([])
25501cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should not be printed in tree output')
25511cb0ef41Sopenharmony_ci  })
25521cb0ef41Sopenharmony_ci
25531cb0ef41Sopenharmony_ci  t.test('global', async t => {
25541cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
25551cb0ef41Sopenharmony_ci      config: { ...parseable, global: true },
25561cb0ef41Sopenharmony_ci      globalPrefixDir: {
25571cb0ef41Sopenharmony_ci        node_modules: {
25581cb0ef41Sopenharmony_ci          a: {
25591cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
25601cb0ef41Sopenharmony_ci              name: 'a',
25611cb0ef41Sopenharmony_ci              version: '1.0.0',
25621cb0ef41Sopenharmony_ci            }),
25631cb0ef41Sopenharmony_ci          },
25641cb0ef41Sopenharmony_ci          b: {
25651cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
25661cb0ef41Sopenharmony_ci              name: 'b',
25671cb0ef41Sopenharmony_ci              version: '1.0.0',
25681cb0ef41Sopenharmony_ci            }),
25691cb0ef41Sopenharmony_ci            node_modules: {
25701cb0ef41Sopenharmony_ci              c: {
25711cb0ef41Sopenharmony_ci                'package.json': JSON.stringify({
25721cb0ef41Sopenharmony_ci                  name: 'c',
25731cb0ef41Sopenharmony_ci                  version: '1.0.0',
25741cb0ef41Sopenharmony_ci                }),
25751cb0ef41Sopenharmony_ci              },
25761cb0ef41Sopenharmony_ci            },
25771cb0ef41Sopenharmony_ci          },
25781cb0ef41Sopenharmony_ci        },
25791cb0ef41Sopenharmony_ci      },
25801cb0ef41Sopenharmony_ci    })
25811cb0ef41Sopenharmony_ci
25821cb0ef41Sopenharmony_ci    await ls.exec([])
25831cb0ef41Sopenharmony_ci    t.matchSnapshot(cleanCwd(result()), 'should print parseable output for global deps')
25841cb0ef41Sopenharmony_ci  })
25851cb0ef41Sopenharmony_ci})
25861cb0ef41Sopenharmony_ci
25871cb0ef41Sopenharmony_cit.test('ignore missing optional deps', async t => {
25881cb0ef41Sopenharmony_ci  const mock = async (t, config = {}) => {
25891cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
25901cb0ef41Sopenharmony_ci      config: config,
25911cb0ef41Sopenharmony_ci      prefixDir: {
25921cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
25931cb0ef41Sopenharmony_ci          name: 'test-npm-ls-ignore-missing-optional',
25941cb0ef41Sopenharmony_ci          version: '1.2.3',
25951cb0ef41Sopenharmony_ci          peerDependencies: {
25961cb0ef41Sopenharmony_ci            'peer-ok': '1',
25971cb0ef41Sopenharmony_ci            'peer-missing': '1',
25981cb0ef41Sopenharmony_ci            'peer-wrong': '1',
25991cb0ef41Sopenharmony_ci            'peer-optional-ok': '1',
26001cb0ef41Sopenharmony_ci            'peer-optional-missing': '1',
26011cb0ef41Sopenharmony_ci            'peer-optional-wrong': '1',
26021cb0ef41Sopenharmony_ci          },
26031cb0ef41Sopenharmony_ci          peerDependenciesMeta: {
26041cb0ef41Sopenharmony_ci            'peer-optional-ok': {
26051cb0ef41Sopenharmony_ci              optional: true,
26061cb0ef41Sopenharmony_ci            },
26071cb0ef41Sopenharmony_ci            'peer-optional-missing': {
26081cb0ef41Sopenharmony_ci              optional: true,
26091cb0ef41Sopenharmony_ci            },
26101cb0ef41Sopenharmony_ci            'peer-optional-wrong': {
26111cb0ef41Sopenharmony_ci              optional: true,
26121cb0ef41Sopenharmony_ci            },
26131cb0ef41Sopenharmony_ci          },
26141cb0ef41Sopenharmony_ci          optionalDependencies: {
26151cb0ef41Sopenharmony_ci            'optional-ok': '1',
26161cb0ef41Sopenharmony_ci            'optional-missing': '1',
26171cb0ef41Sopenharmony_ci            'optional-wrong': '1',
26181cb0ef41Sopenharmony_ci          },
26191cb0ef41Sopenharmony_ci          dependencies: {
26201cb0ef41Sopenharmony_ci            'prod-ok': '1',
26211cb0ef41Sopenharmony_ci            'prod-missing': '1',
26221cb0ef41Sopenharmony_ci            'prod-wrong': '1',
26231cb0ef41Sopenharmony_ci          },
26241cb0ef41Sopenharmony_ci        }),
26251cb0ef41Sopenharmony_ci        node_modules: {
26261cb0ef41Sopenharmony_ci          'prod-ok': {
26271cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'prod-ok', version: '1.2.3' }),
26281cb0ef41Sopenharmony_ci          },
26291cb0ef41Sopenharmony_ci          'prod-wrong': {
26301cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'prod-wrong', version: '3.2.1' }),
26311cb0ef41Sopenharmony_ci          },
26321cb0ef41Sopenharmony_ci          'optional-ok': {
26331cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'optional-ok', version: '1.2.3' }),
26341cb0ef41Sopenharmony_ci          },
26351cb0ef41Sopenharmony_ci          'optional-wrong': {
26361cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'optional-wrong', version: '3.2.1' }),
26371cb0ef41Sopenharmony_ci          },
26381cb0ef41Sopenharmony_ci          'peer-optional-ok': {
26391cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'peer-optional-ok', version: '1.2.3' }),
26401cb0ef41Sopenharmony_ci          },
26411cb0ef41Sopenharmony_ci          'peer-optional-wrong': {
26421cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'peer-optional-wrong', version: '3.2.1' }),
26431cb0ef41Sopenharmony_ci          },
26441cb0ef41Sopenharmony_ci          'peer-ok': {
26451cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'peer-ok', version: '1.2.3' }),
26461cb0ef41Sopenharmony_ci          },
26471cb0ef41Sopenharmony_ci          'peer-wrong': {
26481cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({ name: 'peer-wrong', version: '3.2.1' }),
26491cb0ef41Sopenharmony_ci          },
26501cb0ef41Sopenharmony_ci        },
26511cb0ef41Sopenharmony_ci      },
26521cb0ef41Sopenharmony_ci    })
26531cb0ef41Sopenharmony_ci
26541cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' })
26551cb0ef41Sopenharmony_ci
26561cb0ef41Sopenharmony_ci    return config.json ? jsonParse(result()).problems : cleanCwd(result())
26571cb0ef41Sopenharmony_ci  }
26581cb0ef41Sopenharmony_ci
26591cb0ef41Sopenharmony_ci  t.test('--json', async t => {
26601cb0ef41Sopenharmony_ci    const result = await mock(t, { json: true })
26611cb0ef41Sopenharmony_ci    t.matchSnapshot(result, 'ls --json problems')
26621cb0ef41Sopenharmony_ci  })
26631cb0ef41Sopenharmony_ci
26641cb0ef41Sopenharmony_ci  t.test('--parseable', async t => {
26651cb0ef41Sopenharmony_ci    const result = await mock(t, { parseable: true })
26661cb0ef41Sopenharmony_ci    t.matchSnapshot(result, 'ls --parseable result')
26671cb0ef41Sopenharmony_ci  })
26681cb0ef41Sopenharmony_ci
26691cb0ef41Sopenharmony_ci  t.test('human output', async t => {
26701cb0ef41Sopenharmony_ci    const result = await mock(t)
26711cb0ef41Sopenharmony_ci    t.matchSnapshot(result, 'ls result')
26721cb0ef41Sopenharmony_ci  })
26731cb0ef41Sopenharmony_ci})
26741cb0ef41Sopenharmony_ci
26751cb0ef41Sopenharmony_cit.test('ls --json', async t => {
26761cb0ef41Sopenharmony_ci  const json = { json: true }
26771cb0ef41Sopenharmony_ci  t.test('no args', async t => {
26781cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
26791cb0ef41Sopenharmony_ci      config: {
26801cb0ef41Sopenharmony_ci        ...json,
26811cb0ef41Sopenharmony_ci      },
26821cb0ef41Sopenharmony_ci      prefixDir: {
26831cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
26841cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
26851cb0ef41Sopenharmony_ci          version: '1.0.0',
26861cb0ef41Sopenharmony_ci          dependencies: {
26871cb0ef41Sopenharmony_ci            foo: '^1.0.0',
26881cb0ef41Sopenharmony_ci            chai: '^1.0.0',
26891cb0ef41Sopenharmony_ci          },
26901cb0ef41Sopenharmony_ci        }),
26911cb0ef41Sopenharmony_ci        ...simpleNmFixture,
26921cb0ef41Sopenharmony_ci      },
26931cb0ef41Sopenharmony_ci    })
26941cb0ef41Sopenharmony_ci    await ls.exec([])
26951cb0ef41Sopenharmony_ci    t.same(
26961cb0ef41Sopenharmony_ci      jsonParse(result()),
26971cb0ef41Sopenharmony_ci      {
26981cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
26991cb0ef41Sopenharmony_ci        version: '1.0.0',
27001cb0ef41Sopenharmony_ci        dependencies: {
27011cb0ef41Sopenharmony_ci          foo: {
27021cb0ef41Sopenharmony_ci            version: '1.0.0',
27031cb0ef41Sopenharmony_ci            overridden: false,
27041cb0ef41Sopenharmony_ci            dependencies: {
27051cb0ef41Sopenharmony_ci              dog: {
27061cb0ef41Sopenharmony_ci                version: '1.0.0',
27071cb0ef41Sopenharmony_ci                overridden: false,
27081cb0ef41Sopenharmony_ci              },
27091cb0ef41Sopenharmony_ci            },
27101cb0ef41Sopenharmony_ci          },
27111cb0ef41Sopenharmony_ci          chai: {
27121cb0ef41Sopenharmony_ci            version: '1.0.0',
27131cb0ef41Sopenharmony_ci            overridden: false,
27141cb0ef41Sopenharmony_ci          },
27151cb0ef41Sopenharmony_ci        },
27161cb0ef41Sopenharmony_ci      },
27171cb0ef41Sopenharmony_ci      'should output json representation of dependencies structure'
27181cb0ef41Sopenharmony_ci    )
27191cb0ef41Sopenharmony_ci  })
27201cb0ef41Sopenharmony_ci
27211cb0ef41Sopenharmony_ci  t.test('missing package.json', async t => {
27221cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
27231cb0ef41Sopenharmony_ci      config: {
27241cb0ef41Sopenharmony_ci        ...json,
27251cb0ef41Sopenharmony_ci      },
27261cb0ef41Sopenharmony_ci      prefixDir: {
27271cb0ef41Sopenharmony_ci        ...simpleNmFixture,
27281cb0ef41Sopenharmony_ci      },
27291cb0ef41Sopenharmony_ci    })
27301cb0ef41Sopenharmony_ci    await ls.exec([])
27311cb0ef41Sopenharmony_ci    t.same(
27321cb0ef41Sopenharmony_ci      jsonParse(result()),
27331cb0ef41Sopenharmony_ci      {
27341cb0ef41Sopenharmony_ci        problems: [
27351cb0ef41Sopenharmony_ci          'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai',
27361cb0ef41Sopenharmony_ci          'extraneous: dog@1.0.0 {CWD}/prefix/node_modules/dog',
27371cb0ef41Sopenharmony_ci          'extraneous: foo@1.0.0 {CWD}/prefix/node_modules/foo',
27381cb0ef41Sopenharmony_ci        ],
27391cb0ef41Sopenharmony_ci        dependencies: {
27401cb0ef41Sopenharmony_ci          dog: {
27411cb0ef41Sopenharmony_ci            version: '1.0.0',
27421cb0ef41Sopenharmony_ci            extraneous: true,
27431cb0ef41Sopenharmony_ci            overridden: false,
27441cb0ef41Sopenharmony_ci            problems: [
27451cb0ef41Sopenharmony_ci              'extraneous: dog@1.0.0 {CWD}/prefix/node_modules/dog',
27461cb0ef41Sopenharmony_ci            ],
27471cb0ef41Sopenharmony_ci          },
27481cb0ef41Sopenharmony_ci          foo: {
27491cb0ef41Sopenharmony_ci            version: '1.0.0',
27501cb0ef41Sopenharmony_ci            extraneous: true,
27511cb0ef41Sopenharmony_ci            overridden: false,
27521cb0ef41Sopenharmony_ci            problems: [
27531cb0ef41Sopenharmony_ci              'extraneous: foo@1.0.0 {CWD}/prefix/node_modules/foo',
27541cb0ef41Sopenharmony_ci            ],
27551cb0ef41Sopenharmony_ci            dependencies: {
27561cb0ef41Sopenharmony_ci              dog: {
27571cb0ef41Sopenharmony_ci                version: '1.0.0',
27581cb0ef41Sopenharmony_ci              },
27591cb0ef41Sopenharmony_ci            },
27601cb0ef41Sopenharmony_ci          },
27611cb0ef41Sopenharmony_ci          chai: {
27621cb0ef41Sopenharmony_ci            version: '1.0.0',
27631cb0ef41Sopenharmony_ci            extraneous: true,
27641cb0ef41Sopenharmony_ci            overridden: false,
27651cb0ef41Sopenharmony_ci            problems: [
27661cb0ef41Sopenharmony_ci              'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai',
27671cb0ef41Sopenharmony_ci            ],
27681cb0ef41Sopenharmony_ci          },
27691cb0ef41Sopenharmony_ci        },
27701cb0ef41Sopenharmony_ci      },
27711cb0ef41Sopenharmony_ci      'should output json missing name/version of top-level package'
27721cb0ef41Sopenharmony_ci    )
27731cb0ef41Sopenharmony_ci  })
27741cb0ef41Sopenharmony_ci
27751cb0ef41Sopenharmony_ci  t.test('extraneous deps', async t => {
27761cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
27771cb0ef41Sopenharmony_ci      config: {
27781cb0ef41Sopenharmony_ci        ...json,
27791cb0ef41Sopenharmony_ci      },
27801cb0ef41Sopenharmony_ci      prefixDir: {
27811cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
27821cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
27831cb0ef41Sopenharmony_ci          version: '1.0.0',
27841cb0ef41Sopenharmony_ci          dependencies: {
27851cb0ef41Sopenharmony_ci            foo: '^1.0.0',
27861cb0ef41Sopenharmony_ci          },
27871cb0ef41Sopenharmony_ci        }),
27881cb0ef41Sopenharmony_ci        ...simpleNmFixture,
27891cb0ef41Sopenharmony_ci      },
27901cb0ef41Sopenharmony_ci    })
27911cb0ef41Sopenharmony_ci    await ls.exec([])
27921cb0ef41Sopenharmony_ci    t.same(
27931cb0ef41Sopenharmony_ci      jsonParse(result()),
27941cb0ef41Sopenharmony_ci      {
27951cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
27961cb0ef41Sopenharmony_ci        version: '1.0.0',
27971cb0ef41Sopenharmony_ci        problems: [
27981cb0ef41Sopenharmony_ci          'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai',
27991cb0ef41Sopenharmony_ci        ],
28001cb0ef41Sopenharmony_ci        dependencies: {
28011cb0ef41Sopenharmony_ci          foo: {
28021cb0ef41Sopenharmony_ci            version: '1.0.0',
28031cb0ef41Sopenharmony_ci            overridden: false,
28041cb0ef41Sopenharmony_ci            dependencies: {
28051cb0ef41Sopenharmony_ci              dog: {
28061cb0ef41Sopenharmony_ci                version: '1.0.0',
28071cb0ef41Sopenharmony_ci                overridden: false,
28081cb0ef41Sopenharmony_ci              },
28091cb0ef41Sopenharmony_ci            },
28101cb0ef41Sopenharmony_ci          },
28111cb0ef41Sopenharmony_ci          chai: {
28121cb0ef41Sopenharmony_ci            version: '1.0.0',
28131cb0ef41Sopenharmony_ci            extraneous: true,
28141cb0ef41Sopenharmony_ci            overridden: false,
28151cb0ef41Sopenharmony_ci            problems: [
28161cb0ef41Sopenharmony_ci              'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai',
28171cb0ef41Sopenharmony_ci            ],
28181cb0ef41Sopenharmony_ci          },
28191cb0ef41Sopenharmony_ci        },
28201cb0ef41Sopenharmony_ci      },
28211cb0ef41Sopenharmony_ci      'should output json containing problems info'
28221cb0ef41Sopenharmony_ci    )
28231cb0ef41Sopenharmony_ci  })
28241cb0ef41Sopenharmony_ci
28251cb0ef41Sopenharmony_ci  t.test('overridden dep', async t => {
28261cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
28271cb0ef41Sopenharmony_ci      config: {
28281cb0ef41Sopenharmony_ci        ...json,
28291cb0ef41Sopenharmony_ci      },
28301cb0ef41Sopenharmony_ci      prefixDir: {
28311cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
28321cb0ef41Sopenharmony_ci          name: 'test-overridden',
28331cb0ef41Sopenharmony_ci          version: '1.0.0',
28341cb0ef41Sopenharmony_ci          dependencies: {
28351cb0ef41Sopenharmony_ci            foo: '^1.0.0',
28361cb0ef41Sopenharmony_ci          },
28371cb0ef41Sopenharmony_ci          overrides: {
28381cb0ef41Sopenharmony_ci            bar: '1.0.0',
28391cb0ef41Sopenharmony_ci          },
28401cb0ef41Sopenharmony_ci        }),
28411cb0ef41Sopenharmony_ci        node_modules: {
28421cb0ef41Sopenharmony_ci          foo: {
28431cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
28441cb0ef41Sopenharmony_ci              name: 'foo',
28451cb0ef41Sopenharmony_ci              version: '1.0.0',
28461cb0ef41Sopenharmony_ci              dependencies: {
28471cb0ef41Sopenharmony_ci                bar: '^2.0.0',
28481cb0ef41Sopenharmony_ci              },
28491cb0ef41Sopenharmony_ci            }),
28501cb0ef41Sopenharmony_ci          },
28511cb0ef41Sopenharmony_ci          bar: {
28521cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
28531cb0ef41Sopenharmony_ci              name: 'bar',
28541cb0ef41Sopenharmony_ci              version: '1.0.0',
28551cb0ef41Sopenharmony_ci            }),
28561cb0ef41Sopenharmony_ci          },
28571cb0ef41Sopenharmony_ci        },
28581cb0ef41Sopenharmony_ci      },
28591cb0ef41Sopenharmony_ci    })
28601cb0ef41Sopenharmony_ci
28611cb0ef41Sopenharmony_ci    await ls.exec([])
28621cb0ef41Sopenharmony_ci    t.same(JSON.parse(result()), {
28631cb0ef41Sopenharmony_ci      name: 'test-overridden',
28641cb0ef41Sopenharmony_ci      version: '1.0.0',
28651cb0ef41Sopenharmony_ci      dependencies: {
28661cb0ef41Sopenharmony_ci        foo: {
28671cb0ef41Sopenharmony_ci          version: '1.0.0',
28681cb0ef41Sopenharmony_ci          overridden: false,
28691cb0ef41Sopenharmony_ci          dependencies: {
28701cb0ef41Sopenharmony_ci            bar: {
28711cb0ef41Sopenharmony_ci              version: '1.0.0',
28721cb0ef41Sopenharmony_ci              overridden: true,
28731cb0ef41Sopenharmony_ci            },
28741cb0ef41Sopenharmony_ci          },
28751cb0ef41Sopenharmony_ci        },
28761cb0ef41Sopenharmony_ci      },
28771cb0ef41Sopenharmony_ci    })
28781cb0ef41Sopenharmony_ci  })
28791cb0ef41Sopenharmony_ci
28801cb0ef41Sopenharmony_ci  t.test('missing deps --long', async t => {
28811cb0ef41Sopenharmony_ci    t.plan(3)
28821cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
28831cb0ef41Sopenharmony_ci      config: {
28841cb0ef41Sopenharmony_ci        ...json,
28851cb0ef41Sopenharmony_ci        long: true,
28861cb0ef41Sopenharmony_ci      },
28871cb0ef41Sopenharmony_ci      prefixDir: {
28881cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
28891cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
28901cb0ef41Sopenharmony_ci          version: '1.0.0',
28911cb0ef41Sopenharmony_ci          dependencies: {
28921cb0ef41Sopenharmony_ci            foo: '^1.0.0',
28931cb0ef41Sopenharmony_ci            dog: '^1.0.0',
28941cb0ef41Sopenharmony_ci            chai: '^1.0.0',
28951cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
28961cb0ef41Sopenharmony_ci          },
28971cb0ef41Sopenharmony_ci        }),
28981cb0ef41Sopenharmony_ci        ...simpleNmFixture,
28991cb0ef41Sopenharmony_ci      },
29001cb0ef41Sopenharmony_ci    })
29011cb0ef41Sopenharmony_ci
29021cb0ef41Sopenharmony_ci    await ls.exec([]).catch(err => {
29031cb0ef41Sopenharmony_ci      t.equal(
29041cb0ef41Sopenharmony_ci        cleanCwd(err.message),
29051cb0ef41Sopenharmony_ci        'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0',
29061cb0ef41Sopenharmony_ci        'should log missing dep as error'
29071cb0ef41Sopenharmony_ci      )
29081cb0ef41Sopenharmony_ci      t.equal(err.code, 'ELSPROBLEMS', 'should have ELSPROBLEMS error code')
29091cb0ef41Sopenharmony_ci    })
29101cb0ef41Sopenharmony_ci    t.match(
29111cb0ef41Sopenharmony_ci      jsonParse(result()),
29121cb0ef41Sopenharmony_ci      {
29131cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
29141cb0ef41Sopenharmony_ci        version: '1.0.0',
29151cb0ef41Sopenharmony_ci        problems: ['missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0'],
29161cb0ef41Sopenharmony_ci      },
29171cb0ef41Sopenharmony_ci      'should output json containing problems info'
29181cb0ef41Sopenharmony_ci    )
29191cb0ef41Sopenharmony_ci  })
29201cb0ef41Sopenharmony_ci
29211cb0ef41Sopenharmony_ci  t.test('with filter arg', async t => {
29221cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
29231cb0ef41Sopenharmony_ci      config: {
29241cb0ef41Sopenharmony_ci        ...json,
29251cb0ef41Sopenharmony_ci      },
29261cb0ef41Sopenharmony_ci      prefixDir: {
29271cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
29281cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
29291cb0ef41Sopenharmony_ci          version: '1.0.0',
29301cb0ef41Sopenharmony_ci          dependencies: {
29311cb0ef41Sopenharmony_ci            foo: '^1.0.0',
29321cb0ef41Sopenharmony_ci            chai: '^1.0.0',
29331cb0ef41Sopenharmony_ci          },
29341cb0ef41Sopenharmony_ci        }),
29351cb0ef41Sopenharmony_ci        ...simpleNmFixture,
29361cb0ef41Sopenharmony_ci      },
29371cb0ef41Sopenharmony_ci    })
29381cb0ef41Sopenharmony_ci    await ls.exec(['chai'])
29391cb0ef41Sopenharmony_ci    t.same(
29401cb0ef41Sopenharmony_ci      jsonParse(result()),
29411cb0ef41Sopenharmony_ci      {
29421cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
29431cb0ef41Sopenharmony_ci        version: '1.0.0',
29441cb0ef41Sopenharmony_ci        dependencies: {
29451cb0ef41Sopenharmony_ci          chai: {
29461cb0ef41Sopenharmony_ci            version: '1.0.0',
29471cb0ef41Sopenharmony_ci            overridden: false,
29481cb0ef41Sopenharmony_ci          },
29491cb0ef41Sopenharmony_ci        },
29501cb0ef41Sopenharmony_ci      },
29511cb0ef41Sopenharmony_ci      'should output json contaning only occurrences of filtered by package'
29521cb0ef41Sopenharmony_ci    )
29531cb0ef41Sopenharmony_ci    t.not(process.exitCode, 1, 'should not exit with error code 1')
29541cb0ef41Sopenharmony_ci  })
29551cb0ef41Sopenharmony_ci
29561cb0ef41Sopenharmony_ci  t.test('with filter arg nested dep', async t => {
29571cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
29581cb0ef41Sopenharmony_ci      config: {
29591cb0ef41Sopenharmony_ci        ...json,
29601cb0ef41Sopenharmony_ci      },
29611cb0ef41Sopenharmony_ci      prefixDir: {
29621cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
29631cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
29641cb0ef41Sopenharmony_ci          version: '1.0.0',
29651cb0ef41Sopenharmony_ci          dependencies: {
29661cb0ef41Sopenharmony_ci            foo: '^1.0.0',
29671cb0ef41Sopenharmony_ci            chai: '^1.0.0',
29681cb0ef41Sopenharmony_ci          },
29691cb0ef41Sopenharmony_ci        }),
29701cb0ef41Sopenharmony_ci        ...simpleNmFixture,
29711cb0ef41Sopenharmony_ci      },
29721cb0ef41Sopenharmony_ci    })
29731cb0ef41Sopenharmony_ci    await ls.exec(['dog'])
29741cb0ef41Sopenharmony_ci    t.same(
29751cb0ef41Sopenharmony_ci      jsonParse(result()),
29761cb0ef41Sopenharmony_ci      {
29771cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
29781cb0ef41Sopenharmony_ci        version: '1.0.0',
29791cb0ef41Sopenharmony_ci        dependencies: {
29801cb0ef41Sopenharmony_ci          foo: {
29811cb0ef41Sopenharmony_ci            version: '1.0.0',
29821cb0ef41Sopenharmony_ci            overridden: false,
29831cb0ef41Sopenharmony_ci            dependencies: {
29841cb0ef41Sopenharmony_ci              dog: {
29851cb0ef41Sopenharmony_ci                version: '1.0.0',
29861cb0ef41Sopenharmony_ci                overridden: false,
29871cb0ef41Sopenharmony_ci              },
29881cb0ef41Sopenharmony_ci            },
29891cb0ef41Sopenharmony_ci          },
29901cb0ef41Sopenharmony_ci        },
29911cb0ef41Sopenharmony_ci      },
29921cb0ef41Sopenharmony_ci      'should output json contaning only occurrences of filtered by package'
29931cb0ef41Sopenharmony_ci    )
29941cb0ef41Sopenharmony_ci    t.notOk(jsonParse(result()).dependencies.chai)
29951cb0ef41Sopenharmony_ci  })
29961cb0ef41Sopenharmony_ci
29971cb0ef41Sopenharmony_ci  t.test('with multiple filter args', async t => {
29981cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
29991cb0ef41Sopenharmony_ci      config: {
30001cb0ef41Sopenharmony_ci        ...json,
30011cb0ef41Sopenharmony_ci      },
30021cb0ef41Sopenharmony_ci      prefixDir: {
30031cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
30041cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
30051cb0ef41Sopenharmony_ci          version: '1.0.0',
30061cb0ef41Sopenharmony_ci          dependencies: {
30071cb0ef41Sopenharmony_ci            foo: '^1.0.0',
30081cb0ef41Sopenharmony_ci            chai: '^1.0.0',
30091cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
30101cb0ef41Sopenharmony_ci          },
30111cb0ef41Sopenharmony_ci        }),
30121cb0ef41Sopenharmony_ci        node_modules: {
30131cb0ef41Sopenharmony_ci          ...simpleNmFixture.node_modules,
30141cb0ef41Sopenharmony_ci          ipsum: {
30151cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
30161cb0ef41Sopenharmony_ci              name: 'ipsum',
30171cb0ef41Sopenharmony_ci              version: '1.0.0',
30181cb0ef41Sopenharmony_ci            }),
30191cb0ef41Sopenharmony_ci          },
30201cb0ef41Sopenharmony_ci        },
30211cb0ef41Sopenharmony_ci      },
30221cb0ef41Sopenharmony_ci    })
30231cb0ef41Sopenharmony_ci    await ls.exec(['dog@*', 'chai@1.0.0'])
30241cb0ef41Sopenharmony_ci    t.same(
30251cb0ef41Sopenharmony_ci      jsonParse(result()),
30261cb0ef41Sopenharmony_ci      {
30271cb0ef41Sopenharmony_ci        version: '1.0.0',
30281cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
30291cb0ef41Sopenharmony_ci        dependencies: {
30301cb0ef41Sopenharmony_ci          foo: {
30311cb0ef41Sopenharmony_ci            version: '1.0.0',
30321cb0ef41Sopenharmony_ci            overridden: false,
30331cb0ef41Sopenharmony_ci            dependencies: {
30341cb0ef41Sopenharmony_ci              dog: {
30351cb0ef41Sopenharmony_ci                version: '1.0.0',
30361cb0ef41Sopenharmony_ci                overridden: false,
30371cb0ef41Sopenharmony_ci              },
30381cb0ef41Sopenharmony_ci            },
30391cb0ef41Sopenharmony_ci          },
30401cb0ef41Sopenharmony_ci          chai: {
30411cb0ef41Sopenharmony_ci            version: '1.0.0',
30421cb0ef41Sopenharmony_ci            overridden: false,
30431cb0ef41Sopenharmony_ci          },
30441cb0ef41Sopenharmony_ci        },
30451cb0ef41Sopenharmony_ci      },
30461cb0ef41Sopenharmony_ci      /* eslint-disable-next-line max-len */
30471cb0ef41Sopenharmony_ci      'should output json contaning only occurrences of multiple filtered packages and their ancestors'
30481cb0ef41Sopenharmony_ci    )
30491cb0ef41Sopenharmony_ci  })
30501cb0ef41Sopenharmony_ci
30511cb0ef41Sopenharmony_ci  t.test('with missing filter arg', async t => {
30521cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
30531cb0ef41Sopenharmony_ci      config: {
30541cb0ef41Sopenharmony_ci        ...json,
30551cb0ef41Sopenharmony_ci      },
30561cb0ef41Sopenharmony_ci      prefixDir: {
30571cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
30581cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
30591cb0ef41Sopenharmony_ci          version: '1.0.0',
30601cb0ef41Sopenharmony_ci          dependencies: {
30611cb0ef41Sopenharmony_ci            foo: '^1.0.0',
30621cb0ef41Sopenharmony_ci            chai: '^1.0.0',
30631cb0ef41Sopenharmony_ci          },
30641cb0ef41Sopenharmony_ci        }),
30651cb0ef41Sopenharmony_ci        ...simpleNmFixture,
30661cb0ef41Sopenharmony_ci      },
30671cb0ef41Sopenharmony_ci    })
30681cb0ef41Sopenharmony_ci    await ls.exec(['notadep'])
30691cb0ef41Sopenharmony_ci    t.same(
30701cb0ef41Sopenharmony_ci      jsonParse(result()),
30711cb0ef41Sopenharmony_ci      {
30721cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
30731cb0ef41Sopenharmony_ci        version: '1.0.0',
30741cb0ef41Sopenharmony_ci      },
30751cb0ef41Sopenharmony_ci      'should output json containing no dependencies info'
30761cb0ef41Sopenharmony_ci    )
30771cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1, 'should exit with error code 1')
30781cb0ef41Sopenharmony_ci  })
30791cb0ef41Sopenharmony_ci
30801cb0ef41Sopenharmony_ci  t.test('default --depth value should now be 0', async t => {
30811cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
30821cb0ef41Sopenharmony_ci      config: {
30831cb0ef41Sopenharmony_ci        ...json,
30841cb0ef41Sopenharmony_ci        all: false,
30851cb0ef41Sopenharmony_ci      },
30861cb0ef41Sopenharmony_ci      prefixDir: {
30871cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
30881cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
30891cb0ef41Sopenharmony_ci          version: '1.0.0',
30901cb0ef41Sopenharmony_ci          dependencies: {
30911cb0ef41Sopenharmony_ci            foo: '^1.0.0',
30921cb0ef41Sopenharmony_ci            chai: '^1.0.0',
30931cb0ef41Sopenharmony_ci          },
30941cb0ef41Sopenharmony_ci        }),
30951cb0ef41Sopenharmony_ci        ...simpleNmFixture,
30961cb0ef41Sopenharmony_ci      },
30971cb0ef41Sopenharmony_ci    })
30981cb0ef41Sopenharmony_ci    await ls.exec([])
30991cb0ef41Sopenharmony_ci    t.same(
31001cb0ef41Sopenharmony_ci      jsonParse(result()),
31011cb0ef41Sopenharmony_ci      {
31021cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
31031cb0ef41Sopenharmony_ci        version: '1.0.0',
31041cb0ef41Sopenharmony_ci        dependencies: {
31051cb0ef41Sopenharmony_ci          foo: {
31061cb0ef41Sopenharmony_ci            version: '1.0.0',
31071cb0ef41Sopenharmony_ci            overridden: false,
31081cb0ef41Sopenharmony_ci          },
31091cb0ef41Sopenharmony_ci          chai: {
31101cb0ef41Sopenharmony_ci            version: '1.0.0',
31111cb0ef41Sopenharmony_ci            overridden: false,
31121cb0ef41Sopenharmony_ci          },
31131cb0ef41Sopenharmony_ci        },
31141cb0ef41Sopenharmony_ci      },
31151cb0ef41Sopenharmony_ci      'should output json containing only top-level dependencies'
31161cb0ef41Sopenharmony_ci    )
31171cb0ef41Sopenharmony_ci  })
31181cb0ef41Sopenharmony_ci
31191cb0ef41Sopenharmony_ci  t.test('--depth=0', async t => {
31201cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
31211cb0ef41Sopenharmony_ci      config: {
31221cb0ef41Sopenharmony_ci        ...json,
31231cb0ef41Sopenharmony_ci        all: false,
31241cb0ef41Sopenharmony_ci        depth: 0,
31251cb0ef41Sopenharmony_ci      },
31261cb0ef41Sopenharmony_ci      prefixDir: {
31271cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
31281cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
31291cb0ef41Sopenharmony_ci          version: '1.0.0',
31301cb0ef41Sopenharmony_ci          dependencies: {
31311cb0ef41Sopenharmony_ci            foo: '^1.0.0',
31321cb0ef41Sopenharmony_ci            chai: '^1.0.0',
31331cb0ef41Sopenharmony_ci          },
31341cb0ef41Sopenharmony_ci        }),
31351cb0ef41Sopenharmony_ci        ...simpleNmFixture,
31361cb0ef41Sopenharmony_ci      },
31371cb0ef41Sopenharmony_ci    })
31381cb0ef41Sopenharmony_ci    await ls.exec([])
31391cb0ef41Sopenharmony_ci    t.same(
31401cb0ef41Sopenharmony_ci      jsonParse(result()),
31411cb0ef41Sopenharmony_ci      {
31421cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
31431cb0ef41Sopenharmony_ci        version: '1.0.0',
31441cb0ef41Sopenharmony_ci        dependencies: {
31451cb0ef41Sopenharmony_ci          foo: {
31461cb0ef41Sopenharmony_ci            version: '1.0.0',
31471cb0ef41Sopenharmony_ci            overridden: false,
31481cb0ef41Sopenharmony_ci          },
31491cb0ef41Sopenharmony_ci          chai: {
31501cb0ef41Sopenharmony_ci            version: '1.0.0',
31511cb0ef41Sopenharmony_ci            overridden: false,
31521cb0ef41Sopenharmony_ci          },
31531cb0ef41Sopenharmony_ci        },
31541cb0ef41Sopenharmony_ci      },
31551cb0ef41Sopenharmony_ci      'should output json containing only top-level dependencies'
31561cb0ef41Sopenharmony_ci    )
31571cb0ef41Sopenharmony_ci  })
31581cb0ef41Sopenharmony_ci
31591cb0ef41Sopenharmony_ci  t.test('--depth=1', async t => {
31601cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
31611cb0ef41Sopenharmony_ci      config: {
31621cb0ef41Sopenharmony_ci        ...json,
31631cb0ef41Sopenharmony_ci        all: false,
31641cb0ef41Sopenharmony_ci        depth: 1,
31651cb0ef41Sopenharmony_ci      },
31661cb0ef41Sopenharmony_ci      prefixDir: {
31671cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
31681cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
31691cb0ef41Sopenharmony_ci          version: '1.0.0',
31701cb0ef41Sopenharmony_ci          dependencies: {
31711cb0ef41Sopenharmony_ci            foo: '^1.0.0',
31721cb0ef41Sopenharmony_ci            chai: '^1.0.0',
31731cb0ef41Sopenharmony_ci          },
31741cb0ef41Sopenharmony_ci        }),
31751cb0ef41Sopenharmony_ci        ...simpleNmFixture,
31761cb0ef41Sopenharmony_ci      },
31771cb0ef41Sopenharmony_ci    })
31781cb0ef41Sopenharmony_ci    await ls.exec([])
31791cb0ef41Sopenharmony_ci    t.same(
31801cb0ef41Sopenharmony_ci      jsonParse(result()),
31811cb0ef41Sopenharmony_ci      {
31821cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
31831cb0ef41Sopenharmony_ci        version: '1.0.0',
31841cb0ef41Sopenharmony_ci        dependencies: {
31851cb0ef41Sopenharmony_ci          foo: {
31861cb0ef41Sopenharmony_ci            version: '1.0.0',
31871cb0ef41Sopenharmony_ci            overridden: false,
31881cb0ef41Sopenharmony_ci            dependencies: {
31891cb0ef41Sopenharmony_ci              dog: {
31901cb0ef41Sopenharmony_ci                version: '1.0.0',
31911cb0ef41Sopenharmony_ci                overridden: false,
31921cb0ef41Sopenharmony_ci              },
31931cb0ef41Sopenharmony_ci            },
31941cb0ef41Sopenharmony_ci          },
31951cb0ef41Sopenharmony_ci          chai: {
31961cb0ef41Sopenharmony_ci            version: '1.0.0',
31971cb0ef41Sopenharmony_ci            overridden: false,
31981cb0ef41Sopenharmony_ci          },
31991cb0ef41Sopenharmony_ci        },
32001cb0ef41Sopenharmony_ci      },
32011cb0ef41Sopenharmony_ci      'should output json containing top-level deps and their deps only'
32021cb0ef41Sopenharmony_ci    )
32031cb0ef41Sopenharmony_ci  })
32041cb0ef41Sopenharmony_ci
32051cb0ef41Sopenharmony_ci  t.test('missing/invalid/extraneous', async t => {
32061cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
32071cb0ef41Sopenharmony_ci      config: {
32081cb0ef41Sopenharmony_ci        ...json,
32091cb0ef41Sopenharmony_ci      },
32101cb0ef41Sopenharmony_ci      prefixDir: {
32111cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
32121cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
32131cb0ef41Sopenharmony_ci          version: '1.0.0',
32141cb0ef41Sopenharmony_ci          dependencies: {
32151cb0ef41Sopenharmony_ci            foo: '^2.0.0',
32161cb0ef41Sopenharmony_ci            ipsum: '^1.0.0',
32171cb0ef41Sopenharmony_ci          },
32181cb0ef41Sopenharmony_ci        }),
32191cb0ef41Sopenharmony_ci        ...simpleNmFixture,
32201cb0ef41Sopenharmony_ci      },
32211cb0ef41Sopenharmony_ci    })
32221cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' }, 'should list dep problems')
32231cb0ef41Sopenharmony_ci    t.same(
32241cb0ef41Sopenharmony_ci      jsonParse(result()),
32251cb0ef41Sopenharmony_ci      {
32261cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
32271cb0ef41Sopenharmony_ci        version: '1.0.0',
32281cb0ef41Sopenharmony_ci        problems: [
32291cb0ef41Sopenharmony_ci          'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai',
32301cb0ef41Sopenharmony_ci          'invalid: foo@1.0.0 {CWD}/prefix/node_modules/foo',
32311cb0ef41Sopenharmony_ci          'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0',
32321cb0ef41Sopenharmony_ci        ],
32331cb0ef41Sopenharmony_ci        dependencies: {
32341cb0ef41Sopenharmony_ci          foo: {
32351cb0ef41Sopenharmony_ci            version: '1.0.0',
32361cb0ef41Sopenharmony_ci            invalid: '"^2.0.0" from the root project',
32371cb0ef41Sopenharmony_ci            overridden: false,
32381cb0ef41Sopenharmony_ci            problems: [
32391cb0ef41Sopenharmony_ci              'invalid: foo@1.0.0 {CWD}/prefix/node_modules/foo',
32401cb0ef41Sopenharmony_ci            ],
32411cb0ef41Sopenharmony_ci            dependencies: {
32421cb0ef41Sopenharmony_ci              dog: {
32431cb0ef41Sopenharmony_ci                version: '1.0.0',
32441cb0ef41Sopenharmony_ci                overridden: false,
32451cb0ef41Sopenharmony_ci              },
32461cb0ef41Sopenharmony_ci            },
32471cb0ef41Sopenharmony_ci          },
32481cb0ef41Sopenharmony_ci          chai: {
32491cb0ef41Sopenharmony_ci            version: '1.0.0',
32501cb0ef41Sopenharmony_ci            extraneous: true,
32511cb0ef41Sopenharmony_ci            overridden: false,
32521cb0ef41Sopenharmony_ci            problems: [
32531cb0ef41Sopenharmony_ci              'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai',
32541cb0ef41Sopenharmony_ci            ],
32551cb0ef41Sopenharmony_ci          },
32561cb0ef41Sopenharmony_ci          ipsum: {
32571cb0ef41Sopenharmony_ci            required: '^1.0.0',
32581cb0ef41Sopenharmony_ci            missing: true,
32591cb0ef41Sopenharmony_ci            problems: ['missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0'],
32601cb0ef41Sopenharmony_ci          },
32611cb0ef41Sopenharmony_ci        },
32621cb0ef41Sopenharmony_ci        error: {
32631cb0ef41Sopenharmony_ci          code: 'ELSPROBLEMS',
32641cb0ef41Sopenharmony_ci          summary: [
32651cb0ef41Sopenharmony_ci            'extraneous: chai@1.0.0 {CWD}/prefix/node_modules/chai',
32661cb0ef41Sopenharmony_ci            'invalid: foo@1.0.0 {CWD}/prefix/node_modules/foo',
32671cb0ef41Sopenharmony_ci            'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0',
32681cb0ef41Sopenharmony_ci          ].join('\n'),
32691cb0ef41Sopenharmony_ci          detail: '',
32701cb0ef41Sopenharmony_ci        },
32711cb0ef41Sopenharmony_ci      },
32721cb0ef41Sopenharmony_ci      'should output json containing top-level deps and their deps only'
32731cb0ef41Sopenharmony_ci    )
32741cb0ef41Sopenharmony_ci  })
32751cb0ef41Sopenharmony_ci
32761cb0ef41Sopenharmony_ci  t.test('--dev', async t => {
32771cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
32781cb0ef41Sopenharmony_ci      config: {
32791cb0ef41Sopenharmony_ci        ...json,
32801cb0ef41Sopenharmony_ci        omit: ['prod', 'optional', 'peer'],
32811cb0ef41Sopenharmony_ci      },
32821cb0ef41Sopenharmony_ci      prefixDir: {
32831cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
32841cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
32851cb0ef41Sopenharmony_ci          version: '1.0.0',
32861cb0ef41Sopenharmony_ci          dependencies: {
32871cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
32881cb0ef41Sopenharmony_ci            chai: '^1.0.0',
32891cb0ef41Sopenharmony_ci          },
32901cb0ef41Sopenharmony_ci          devDependencies: {
32911cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
32921cb0ef41Sopenharmony_ci          },
32931cb0ef41Sopenharmony_ci          optionalDependencies: {
32941cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
32951cb0ef41Sopenharmony_ci          },
32961cb0ef41Sopenharmony_ci          peerDependencies: {
32971cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
32981cb0ef41Sopenharmony_ci          },
32991cb0ef41Sopenharmony_ci        }),
33001cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
33011cb0ef41Sopenharmony_ci      },
33021cb0ef41Sopenharmony_ci    })
33031cb0ef41Sopenharmony_ci    await ls.exec([])
33041cb0ef41Sopenharmony_ci    t.same(
33051cb0ef41Sopenharmony_ci      jsonParse(result()),
33061cb0ef41Sopenharmony_ci      {
33071cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
33081cb0ef41Sopenharmony_ci        version: '1.0.0',
33091cb0ef41Sopenharmony_ci        dependencies: {
33101cb0ef41Sopenharmony_ci          'dev-dep': {
33111cb0ef41Sopenharmony_ci            version: '1.0.0',
33121cb0ef41Sopenharmony_ci            overridden: false,
33131cb0ef41Sopenharmony_ci            dependencies: {
33141cb0ef41Sopenharmony_ci              foo: {
33151cb0ef41Sopenharmony_ci                version: '1.0.0',
33161cb0ef41Sopenharmony_ci                overridden: false,
33171cb0ef41Sopenharmony_ci                dependencies: {
33181cb0ef41Sopenharmony_ci                  dog: {
33191cb0ef41Sopenharmony_ci                    version: '1.0.0',
33201cb0ef41Sopenharmony_ci                    overridden: false,
33211cb0ef41Sopenharmony_ci                  },
33221cb0ef41Sopenharmony_ci                },
33231cb0ef41Sopenharmony_ci              },
33241cb0ef41Sopenharmony_ci            },
33251cb0ef41Sopenharmony_ci          },
33261cb0ef41Sopenharmony_ci        },
33271cb0ef41Sopenharmony_ci      },
33281cb0ef41Sopenharmony_ci      'should output json containing dev deps'
33291cb0ef41Sopenharmony_ci    )
33301cb0ef41Sopenharmony_ci  })
33311cb0ef41Sopenharmony_ci
33321cb0ef41Sopenharmony_ci  t.test('--link', async t => {
33331cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
33341cb0ef41Sopenharmony_ci      config: {
33351cb0ef41Sopenharmony_ci        ...json,
33361cb0ef41Sopenharmony_ci        link: true,
33371cb0ef41Sopenharmony_ci      },
33381cb0ef41Sopenharmony_ci      prefixDir: {
33391cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
33401cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
33411cb0ef41Sopenharmony_ci          version: '1.0.0',
33421cb0ef41Sopenharmony_ci          dependencies: {
33431cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
33441cb0ef41Sopenharmony_ci            chai: '^1.0.0',
33451cb0ef41Sopenharmony_ci            'linked-dep': '^1.0.0',
33461cb0ef41Sopenharmony_ci          },
33471cb0ef41Sopenharmony_ci          devDependencies: {
33481cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
33491cb0ef41Sopenharmony_ci          },
33501cb0ef41Sopenharmony_ci          optionalDependencies: {
33511cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
33521cb0ef41Sopenharmony_ci          },
33531cb0ef41Sopenharmony_ci          peerDependencies: {
33541cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
33551cb0ef41Sopenharmony_ci          },
33561cb0ef41Sopenharmony_ci        }),
33571cb0ef41Sopenharmony_ci        'linked-dep': {
33581cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
33591cb0ef41Sopenharmony_ci            name: 'linked-dep',
33601cb0ef41Sopenharmony_ci            version: '1.0.0',
33611cb0ef41Sopenharmony_ci          }),
33621cb0ef41Sopenharmony_ci        },
33631cb0ef41Sopenharmony_ci        node_modules: {
33641cb0ef41Sopenharmony_ci          'linked-dep': t.fixture('symlink', '../linked-dep'),
33651cb0ef41Sopenharmony_ci          ...diffDepTypesNmFixture.node_modules,
33661cb0ef41Sopenharmony_ci        },
33671cb0ef41Sopenharmony_ci      },
33681cb0ef41Sopenharmony_ci    })
33691cb0ef41Sopenharmony_ci    await ls.exec([])
33701cb0ef41Sopenharmony_ci    t.same(
33711cb0ef41Sopenharmony_ci      jsonParse(result()),
33721cb0ef41Sopenharmony_ci      {
33731cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
33741cb0ef41Sopenharmony_ci        version: '1.0.0',
33751cb0ef41Sopenharmony_ci        dependencies: {
33761cb0ef41Sopenharmony_ci          'linked-dep': {
33771cb0ef41Sopenharmony_ci            version: '1.0.0',
33781cb0ef41Sopenharmony_ci            resolved: 'file:../linked-dep',
33791cb0ef41Sopenharmony_ci            overridden: false,
33801cb0ef41Sopenharmony_ci          },
33811cb0ef41Sopenharmony_ci        },
33821cb0ef41Sopenharmony_ci      },
33831cb0ef41Sopenharmony_ci      'should output json containing linked deps'
33841cb0ef41Sopenharmony_ci    )
33851cb0ef41Sopenharmony_ci  })
33861cb0ef41Sopenharmony_ci
33871cb0ef41Sopenharmony_ci  t.test('--production', async t => {
33881cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
33891cb0ef41Sopenharmony_ci      config: {
33901cb0ef41Sopenharmony_ci        ...json,
33911cb0ef41Sopenharmony_ci        omit: ['dev', 'peer'],
33921cb0ef41Sopenharmony_ci      },
33931cb0ef41Sopenharmony_ci      prefixDir: {
33941cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
33951cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
33961cb0ef41Sopenharmony_ci          version: '1.0.0',
33971cb0ef41Sopenharmony_ci          dependencies: {
33981cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
33991cb0ef41Sopenharmony_ci            chai: '^1.0.0',
34001cb0ef41Sopenharmony_ci          },
34011cb0ef41Sopenharmony_ci          devDependencies: {
34021cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
34031cb0ef41Sopenharmony_ci          },
34041cb0ef41Sopenharmony_ci          optionalDependencies: {
34051cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
34061cb0ef41Sopenharmony_ci          },
34071cb0ef41Sopenharmony_ci          peerDependencies: {
34081cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
34091cb0ef41Sopenharmony_ci          },
34101cb0ef41Sopenharmony_ci        }),
34111cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
34121cb0ef41Sopenharmony_ci      },
34131cb0ef41Sopenharmony_ci    })
34141cb0ef41Sopenharmony_ci    await ls.exec([])
34151cb0ef41Sopenharmony_ci    t.same(
34161cb0ef41Sopenharmony_ci      jsonParse(result()),
34171cb0ef41Sopenharmony_ci      {
34181cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
34191cb0ef41Sopenharmony_ci        version: '1.0.0',
34201cb0ef41Sopenharmony_ci        dependencies: {
34211cb0ef41Sopenharmony_ci          chai: {
34221cb0ef41Sopenharmony_ci            version: '1.0.0',
34231cb0ef41Sopenharmony_ci            overridden: false,
34241cb0ef41Sopenharmony_ci          },
34251cb0ef41Sopenharmony_ci          'optional-dep': {
34261cb0ef41Sopenharmony_ci            version: '1.0.0',
34271cb0ef41Sopenharmony_ci            overridden: false,
34281cb0ef41Sopenharmony_ci          },
34291cb0ef41Sopenharmony_ci          'prod-dep': {
34301cb0ef41Sopenharmony_ci            version: '1.0.0',
34311cb0ef41Sopenharmony_ci            overridden: false,
34321cb0ef41Sopenharmony_ci            dependencies: {
34331cb0ef41Sopenharmony_ci              dog: {
34341cb0ef41Sopenharmony_ci                version: '2.0.0',
34351cb0ef41Sopenharmony_ci                overridden: false,
34361cb0ef41Sopenharmony_ci              },
34371cb0ef41Sopenharmony_ci            },
34381cb0ef41Sopenharmony_ci          },
34391cb0ef41Sopenharmony_ci        },
34401cb0ef41Sopenharmony_ci      },
34411cb0ef41Sopenharmony_ci      'should output json containing production deps'
34421cb0ef41Sopenharmony_ci    )
34431cb0ef41Sopenharmony_ci  })
34441cb0ef41Sopenharmony_ci
34451cb0ef41Sopenharmony_ci  t.test('from lockfile', async t => {
34461cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
34471cb0ef41Sopenharmony_ci      config: {
34481cb0ef41Sopenharmony_ci        ...json,
34491cb0ef41Sopenharmony_ci      },
34501cb0ef41Sopenharmony_ci      prefixDir: {
34511cb0ef41Sopenharmony_ci        node_modules: {
34521cb0ef41Sopenharmony_ci          '@isaacs': {
34531cb0ef41Sopenharmony_ci            'dedupe-tests-a': {
34541cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
34551cb0ef41Sopenharmony_ci                name: '@isaacs/dedupe-tests-a',
34561cb0ef41Sopenharmony_ci                version: '1.0.1',
34571cb0ef41Sopenharmony_ci              }),
34581cb0ef41Sopenharmony_ci              node_modules: {
34591cb0ef41Sopenharmony_ci                '@isaacs': {
34601cb0ef41Sopenharmony_ci                  'dedupe-tests-b': {
34611cb0ef41Sopenharmony_ci                    name: '@isaacs/dedupe-tests-b',
34621cb0ef41Sopenharmony_ci                    version: '1.0.0',
34631cb0ef41Sopenharmony_ci                  },
34641cb0ef41Sopenharmony_ci                },
34651cb0ef41Sopenharmony_ci              },
34661cb0ef41Sopenharmony_ci            },
34671cb0ef41Sopenharmony_ci            'dedupe-tests-b': {
34681cb0ef41Sopenharmony_ci              'package.json': JSON.stringify({
34691cb0ef41Sopenharmony_ci                name: '@isaacs/dedupe-tests-b',
34701cb0ef41Sopenharmony_ci                version: '2.0.0',
34711cb0ef41Sopenharmony_ci              }),
34721cb0ef41Sopenharmony_ci            },
34731cb0ef41Sopenharmony_ci          },
34741cb0ef41Sopenharmony_ci        },
34751cb0ef41Sopenharmony_ci        'package-lock.json': JSON.stringify({
34761cb0ef41Sopenharmony_ci          name: 'dedupe-lockfile',
34771cb0ef41Sopenharmony_ci          version: '1.0.0',
34781cb0ef41Sopenharmony_ci          lockfileVersion: 2,
34791cb0ef41Sopenharmony_ci          requires: true,
34801cb0ef41Sopenharmony_ci          packages: {
34811cb0ef41Sopenharmony_ci            '': {
34821cb0ef41Sopenharmony_ci              name: 'dedupe-lockfile',
34831cb0ef41Sopenharmony_ci              version: '1.0.0',
34841cb0ef41Sopenharmony_ci              dependencies: {
34851cb0ef41Sopenharmony_ci                '@isaacs/dedupe-tests-a': '1.0.1',
34861cb0ef41Sopenharmony_ci                '@isaacs/dedupe-tests-b': '1||2',
34871cb0ef41Sopenharmony_ci              },
34881cb0ef41Sopenharmony_ci            },
34891cb0ef41Sopenharmony_ci            'node_modules/@isaacs/dedupe-tests-a': {
34901cb0ef41Sopenharmony_ci              name: '@isaacs/dedupe-tests-a',
34911cb0ef41Sopenharmony_ci              version: '1.0.1',
34921cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
34931cb0ef41Sopenharmony_ci              resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-a/-/dedupe-tests-a-1.0.1.tgz',
34941cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
34951cb0ef41Sopenharmony_ci              integrity: 'sha512-8AN9lNCcBt5Xeje7fMEEpp5K3rgcAzIpTtAjYb/YMUYu8SbIVF6wz0WqACDVKvpQOUcSfNHZQNLNmue0QSwXOQ==',
34961cb0ef41Sopenharmony_ci              dependencies: {
34971cb0ef41Sopenharmony_ci                '@isaacs/dedupe-tests-b': '1',
34981cb0ef41Sopenharmony_ci              },
34991cb0ef41Sopenharmony_ci            },
35001cb0ef41Sopenharmony_ci            'node_modules/@isaacs/dedupe-tests-a/node_modules/@isaacs/dedupe-tests-b': {
35011cb0ef41Sopenharmony_ci              name: '@isaacs/dedupe-tests-b',
35021cb0ef41Sopenharmony_ci              version: '1.0.0',
35031cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35041cb0ef41Sopenharmony_ci              resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-1.0.0.tgz',
35051cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35061cb0ef41Sopenharmony_ci              integrity: 'sha512-3nmvzIb8QL8OXODzipwoV3U8h9OQD9g9RwOPuSBQqjqSg9JZR1CCFOWNsDUtOfmwY8HFUJV9EAZ124uhqVxq+w==',
35071cb0ef41Sopenharmony_ci            },
35081cb0ef41Sopenharmony_ci            'node_modules/@isaacs/dedupe-tests-b': {
35091cb0ef41Sopenharmony_ci              name: '@isaacs/dedupe-tests-b',
35101cb0ef41Sopenharmony_ci              version: '2.0.0',
35111cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35121cb0ef41Sopenharmony_ci              resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-2.0.0.tgz',
35131cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35141cb0ef41Sopenharmony_ci              integrity: 'sha512-KTYkpRv9EzlmCg4Gsm/jpclWmRYFCXow8GZKJXjK08sIZBlElTZEa5Bw/UQxIvEfcKmWXczSqItD49Kr8Ax4UA==',
35151cb0ef41Sopenharmony_ci            },
35161cb0ef41Sopenharmony_ci          },
35171cb0ef41Sopenharmony_ci          dependencies: {
35181cb0ef41Sopenharmony_ci            '@isaacs/dedupe-tests-a': {
35191cb0ef41Sopenharmony_ci              version: '1.0.1',
35201cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35211cb0ef41Sopenharmony_ci              resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-a/-/dedupe-tests-a-1.0.1.tgz',
35221cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35231cb0ef41Sopenharmony_ci              integrity: 'sha512-8AN9lNCcBt5Xeje7fMEEpp5K3rgcAzIpTtAjYb/YMUYu8SbIVF6wz0WqACDVKvpQOUcSfNHZQNLNmue0QSwXOQ==',
35241cb0ef41Sopenharmony_ci              requires: {
35251cb0ef41Sopenharmony_ci                '@isaacs/dedupe-tests-b': '1',
35261cb0ef41Sopenharmony_ci              },
35271cb0ef41Sopenharmony_ci              dependencies: {
35281cb0ef41Sopenharmony_ci                '@isaacs/dedupe-tests-b': {
35291cb0ef41Sopenharmony_ci                  version: '1.0.0',
35301cb0ef41Sopenharmony_ci                  /* eslint-disable-next-line max-len */
35311cb0ef41Sopenharmony_ci                  resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-1.0.0.tgz',
35321cb0ef41Sopenharmony_ci                  /* eslint-disable-next-line max-len */
35331cb0ef41Sopenharmony_ci                  integrity: 'sha512-3nmvzIb8QL8OXODzipwoV3U8h9OQD9g9RwOPuSBQqjqSg9JZR1CCFOWNsDUtOfmwY8HFUJV9EAZ124uhqVxq+w==',
35341cb0ef41Sopenharmony_ci                },
35351cb0ef41Sopenharmony_ci              },
35361cb0ef41Sopenharmony_ci            },
35371cb0ef41Sopenharmony_ci            '@isaacs/dedupe-tests-b': {
35381cb0ef41Sopenharmony_ci              version: '2.0.0',
35391cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35401cb0ef41Sopenharmony_ci              resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-2.0.0.tgz',
35411cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
35421cb0ef41Sopenharmony_ci              integrity: 'sha512-KTYkpRv9EzlmCg4Gsm/jpclWmRYFCXow8GZKJXjK08sIZBlElTZEa5Bw/UQxIvEfcKmWXczSqItD49Kr8Ax4UA==',
35431cb0ef41Sopenharmony_ci            },
35441cb0ef41Sopenharmony_ci          },
35451cb0ef41Sopenharmony_ci        }),
35461cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
35471cb0ef41Sopenharmony_ci          name: 'dedupe-lockfile',
35481cb0ef41Sopenharmony_ci          version: '1.0.0',
35491cb0ef41Sopenharmony_ci          dependencies: {
35501cb0ef41Sopenharmony_ci            '@isaacs/dedupe-tests-a': '1.0.1',
35511cb0ef41Sopenharmony_ci            '@isaacs/dedupe-tests-b': '1||2',
35521cb0ef41Sopenharmony_ci          },
35531cb0ef41Sopenharmony_ci        }),
35541cb0ef41Sopenharmony_ci      },
35551cb0ef41Sopenharmony_ci    })
35561cb0ef41Sopenharmony_ci    await ls.exec([])
35571cb0ef41Sopenharmony_ci    t.same(
35581cb0ef41Sopenharmony_ci      jsonParse(result()),
35591cb0ef41Sopenharmony_ci      {
35601cb0ef41Sopenharmony_ci        version: '1.0.0',
35611cb0ef41Sopenharmony_ci        name: 'dedupe-lockfile',
35621cb0ef41Sopenharmony_ci        dependencies: {
35631cb0ef41Sopenharmony_ci          '@isaacs/dedupe-tests-a': {
35641cb0ef41Sopenharmony_ci            version: '1.0.1',
35651cb0ef41Sopenharmony_ci            overridden: false,
35661cb0ef41Sopenharmony_ci            resolved:
35671cb0ef41Sopenharmony_ci              'https://registry.npmjs.org/@isaacs/dedupe-tests-a/-/dedupe-tests-a-1.0.1.tgz',
35681cb0ef41Sopenharmony_ci            dependencies: {
35691cb0ef41Sopenharmony_ci              '@isaacs/dedupe-tests-b': {
35701cb0ef41Sopenharmony_ci                resolved:
35711cb0ef41Sopenharmony_ci                  'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-1.0.0.tgz',
35721cb0ef41Sopenharmony_ci                extraneous: true,
35731cb0ef41Sopenharmony_ci                overridden: false,
35741cb0ef41Sopenharmony_ci                problems: [
35751cb0ef41Sopenharmony_ci                  /* eslint-disable-next-line max-len */
35761cb0ef41Sopenharmony_ci                  'extraneous: @isaacs/dedupe-tests-b@ {CWD}/prefix/node_modules/@isaacs/dedupe-tests-a/node_modules/@isaacs/dedupe-tests-b',
35771cb0ef41Sopenharmony_ci                ],
35781cb0ef41Sopenharmony_ci              },
35791cb0ef41Sopenharmony_ci            },
35801cb0ef41Sopenharmony_ci          },
35811cb0ef41Sopenharmony_ci          '@isaacs/dedupe-tests-b': {
35821cb0ef41Sopenharmony_ci            version: '2.0.0',
35831cb0ef41Sopenharmony_ci            overridden: false,
35841cb0ef41Sopenharmony_ci            resolved:
35851cb0ef41Sopenharmony_ci              'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-2.0.0.tgz',
35861cb0ef41Sopenharmony_ci          },
35871cb0ef41Sopenharmony_ci        },
35881cb0ef41Sopenharmony_ci        problems: [
35891cb0ef41Sopenharmony_ci          /* eslint-disable-next-line max-len */
35901cb0ef41Sopenharmony_ci          'extraneous: @isaacs/dedupe-tests-b@ {CWD}/prefix/node_modules/@isaacs/dedupe-tests-a/node_modules/@isaacs/dedupe-tests-b',
35911cb0ef41Sopenharmony_ci        ],
35921cb0ef41Sopenharmony_ci      },
35931cb0ef41Sopenharmony_ci      'should output json containing only prod deps'
35941cb0ef41Sopenharmony_ci    )
35951cb0ef41Sopenharmony_ci  })
35961cb0ef41Sopenharmony_ci
35971cb0ef41Sopenharmony_ci  t.test('--long', async t => {
35981cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
35991cb0ef41Sopenharmony_ci      config: {
36001cb0ef41Sopenharmony_ci        ...json,
36011cb0ef41Sopenharmony_ci        long: true,
36021cb0ef41Sopenharmony_ci      },
36031cb0ef41Sopenharmony_ci      prefixDir: {
36041cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
36051cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
36061cb0ef41Sopenharmony_ci          version: '1.0.0',
36071cb0ef41Sopenharmony_ci          dependencies: {
36081cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
36091cb0ef41Sopenharmony_ci            chai: '^1.0.0',
36101cb0ef41Sopenharmony_ci          },
36111cb0ef41Sopenharmony_ci          devDependencies: {
36121cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
36131cb0ef41Sopenharmony_ci          },
36141cb0ef41Sopenharmony_ci          optionalDependencies: {
36151cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
36161cb0ef41Sopenharmony_ci          },
36171cb0ef41Sopenharmony_ci          peerDependencies: {
36181cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
36191cb0ef41Sopenharmony_ci          },
36201cb0ef41Sopenharmony_ci        }),
36211cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
36221cb0ef41Sopenharmony_ci      },
36231cb0ef41Sopenharmony_ci    })
36241cb0ef41Sopenharmony_ci    await ls.exec([])
36251cb0ef41Sopenharmony_ci    t.same(
36261cb0ef41Sopenharmony_ci      jsonParse(result()),
36271cb0ef41Sopenharmony_ci      {
36281cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
36291cb0ef41Sopenharmony_ci        version: '1.0.0',
36301cb0ef41Sopenharmony_ci        dependencies: {
36311cb0ef41Sopenharmony_ci          'peer-dep': {
36321cb0ef41Sopenharmony_ci            name: 'peer-dep',
36331cb0ef41Sopenharmony_ci            overridden: false,
36341cb0ef41Sopenharmony_ci            description: 'Peer-dep description here',
36351cb0ef41Sopenharmony_ci            version: '1.0.0',
36361cb0ef41Sopenharmony_ci            _id: 'peer-dep@1.0.0',
36371cb0ef41Sopenharmony_ci            devDependencies: {},
36381cb0ef41Sopenharmony_ci            peerDependencies: {},
36391cb0ef41Sopenharmony_ci            _dependencies: {},
36401cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/peer-dep',
36411cb0ef41Sopenharmony_ci            extraneous: false,
36421cb0ef41Sopenharmony_ci          },
36431cb0ef41Sopenharmony_ci          'dev-dep': {
36441cb0ef41Sopenharmony_ci            name: 'dev-dep',
36451cb0ef41Sopenharmony_ci            overridden: false,
36461cb0ef41Sopenharmony_ci            description: 'A DEV dep kind of dep',
36471cb0ef41Sopenharmony_ci            version: '1.0.0',
36481cb0ef41Sopenharmony_ci            dependencies: {
36491cb0ef41Sopenharmony_ci              foo: {
36501cb0ef41Sopenharmony_ci                name: 'foo',
36511cb0ef41Sopenharmony_ci                version: '1.0.0',
36521cb0ef41Sopenharmony_ci                overridden: false,
36531cb0ef41Sopenharmony_ci                dependencies: {
36541cb0ef41Sopenharmony_ci                  dog: {
36551cb0ef41Sopenharmony_ci                    name: 'dog',
36561cb0ef41Sopenharmony_ci                    overridden: false,
36571cb0ef41Sopenharmony_ci                    version: '1.0.0',
36581cb0ef41Sopenharmony_ci                    _id: 'dog@1.0.0',
36591cb0ef41Sopenharmony_ci                    devDependencies: {},
36601cb0ef41Sopenharmony_ci                    peerDependencies: {},
36611cb0ef41Sopenharmony_ci                    _dependencies: {},
36621cb0ef41Sopenharmony_ci                    path: '{CWD}/prefix/node_modules/dog',
36631cb0ef41Sopenharmony_ci                    extraneous: false,
36641cb0ef41Sopenharmony_ci                  },
36651cb0ef41Sopenharmony_ci                },
36661cb0ef41Sopenharmony_ci                _id: 'foo@1.0.0',
36671cb0ef41Sopenharmony_ci                devDependencies: {},
36681cb0ef41Sopenharmony_ci                peerDependencies: {},
36691cb0ef41Sopenharmony_ci                _dependencies: { dog: '^1.0.0' },
36701cb0ef41Sopenharmony_ci                path: '{CWD}/prefix/node_modules/foo',
36711cb0ef41Sopenharmony_ci                extraneous: false,
36721cb0ef41Sopenharmony_ci              },
36731cb0ef41Sopenharmony_ci            },
36741cb0ef41Sopenharmony_ci            _id: 'dev-dep@1.0.0',
36751cb0ef41Sopenharmony_ci            devDependencies: {},
36761cb0ef41Sopenharmony_ci            peerDependencies: {},
36771cb0ef41Sopenharmony_ci            _dependencies: { foo: '^1.0.0' },
36781cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/dev-dep',
36791cb0ef41Sopenharmony_ci            extraneous: false,
36801cb0ef41Sopenharmony_ci          },
36811cb0ef41Sopenharmony_ci          chai: {
36821cb0ef41Sopenharmony_ci            name: 'chai',
36831cb0ef41Sopenharmony_ci            overridden: false,
36841cb0ef41Sopenharmony_ci            version: '1.0.0',
36851cb0ef41Sopenharmony_ci            _id: 'chai@1.0.0',
36861cb0ef41Sopenharmony_ci            devDependencies: {},
36871cb0ef41Sopenharmony_ci            peerDependencies: {},
36881cb0ef41Sopenharmony_ci            _dependencies: {},
36891cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/chai',
36901cb0ef41Sopenharmony_ci            extraneous: false,
36911cb0ef41Sopenharmony_ci          },
36921cb0ef41Sopenharmony_ci          'optional-dep': {
36931cb0ef41Sopenharmony_ci            name: 'optional-dep',
36941cb0ef41Sopenharmony_ci            overridden: false,
36951cb0ef41Sopenharmony_ci            description: 'Maybe a dep?',
36961cb0ef41Sopenharmony_ci            version: '1.0.0',
36971cb0ef41Sopenharmony_ci            _id: 'optional-dep@1.0.0',
36981cb0ef41Sopenharmony_ci            devDependencies: {},
36991cb0ef41Sopenharmony_ci            peerDependencies: {},
37001cb0ef41Sopenharmony_ci            _dependencies: {},
37011cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/optional-dep',
37021cb0ef41Sopenharmony_ci            extraneous: false,
37031cb0ef41Sopenharmony_ci          },
37041cb0ef41Sopenharmony_ci          'prod-dep': {
37051cb0ef41Sopenharmony_ci            name: 'prod-dep',
37061cb0ef41Sopenharmony_ci            overridden: false,
37071cb0ef41Sopenharmony_ci            description: 'A PROD dep kind of dep',
37081cb0ef41Sopenharmony_ci            version: '1.0.0',
37091cb0ef41Sopenharmony_ci            dependencies: {
37101cb0ef41Sopenharmony_ci              dog: {
37111cb0ef41Sopenharmony_ci                name: 'dog',
37121cb0ef41Sopenharmony_ci                overridden: false,
37131cb0ef41Sopenharmony_ci                description: 'A dep that bars',
37141cb0ef41Sopenharmony_ci                version: '2.0.0',
37151cb0ef41Sopenharmony_ci                _id: 'dog@2.0.0',
37161cb0ef41Sopenharmony_ci                devDependencies: {},
37171cb0ef41Sopenharmony_ci                peerDependencies: {},
37181cb0ef41Sopenharmony_ci                _dependencies: {},
37191cb0ef41Sopenharmony_ci                path: '{CWD}/prefix/node_modules/prod-dep/node_modules/dog',
37201cb0ef41Sopenharmony_ci                extraneous: false,
37211cb0ef41Sopenharmony_ci              },
37221cb0ef41Sopenharmony_ci            },
37231cb0ef41Sopenharmony_ci            _id: 'prod-dep@1.0.0',
37241cb0ef41Sopenharmony_ci            devDependencies: {},
37251cb0ef41Sopenharmony_ci            peerDependencies: {},
37261cb0ef41Sopenharmony_ci            _dependencies: { dog: '^2.0.0' },
37271cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/prod-dep',
37281cb0ef41Sopenharmony_ci            extraneous: false,
37291cb0ef41Sopenharmony_ci          },
37301cb0ef41Sopenharmony_ci        },
37311cb0ef41Sopenharmony_ci        devDependencies: { 'dev-dep': '^1.0.0' },
37321cb0ef41Sopenharmony_ci        optionalDependencies: { 'optional-dep': '^1.0.0' },
37331cb0ef41Sopenharmony_ci        peerDependencies: { 'peer-dep': '^1.0.0' },
37341cb0ef41Sopenharmony_ci        _id: 'test-npm-ls@1.0.0',
37351cb0ef41Sopenharmony_ci        _dependencies: { 'prod-dep': '^1.0.0', chai: '^1.0.0', 'optional-dep': '^1.0.0' },
37361cb0ef41Sopenharmony_ci        path: '{CWD}/prefix',
37371cb0ef41Sopenharmony_ci        extraneous: false,
37381cb0ef41Sopenharmony_ci      },
37391cb0ef41Sopenharmony_ci      'should output long json info'
37401cb0ef41Sopenharmony_ci    )
37411cb0ef41Sopenharmony_ci  })
37421cb0ef41Sopenharmony_ci
37431cb0ef41Sopenharmony_ci  t.test('--long --depth=0', async t => {
37441cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
37451cb0ef41Sopenharmony_ci      config: {
37461cb0ef41Sopenharmony_ci        ...json,
37471cb0ef41Sopenharmony_ci        all: false,
37481cb0ef41Sopenharmony_ci        depth: 0,
37491cb0ef41Sopenharmony_ci        long: true,
37501cb0ef41Sopenharmony_ci      },
37511cb0ef41Sopenharmony_ci      prefixDir: {
37521cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
37531cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
37541cb0ef41Sopenharmony_ci          version: '1.0.0',
37551cb0ef41Sopenharmony_ci          dependencies: {
37561cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
37571cb0ef41Sopenharmony_ci            chai: '^1.0.0',
37581cb0ef41Sopenharmony_ci          },
37591cb0ef41Sopenharmony_ci          devDependencies: {
37601cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
37611cb0ef41Sopenharmony_ci          },
37621cb0ef41Sopenharmony_ci          optionalDependencies: {
37631cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
37641cb0ef41Sopenharmony_ci          },
37651cb0ef41Sopenharmony_ci          peerDependencies: {
37661cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
37671cb0ef41Sopenharmony_ci          },
37681cb0ef41Sopenharmony_ci        }),
37691cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
37701cb0ef41Sopenharmony_ci      },
37711cb0ef41Sopenharmony_ci    })
37721cb0ef41Sopenharmony_ci    await ls.exec([])
37731cb0ef41Sopenharmony_ci    t.same(
37741cb0ef41Sopenharmony_ci      jsonParse(result()),
37751cb0ef41Sopenharmony_ci      {
37761cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
37771cb0ef41Sopenharmony_ci        version: '1.0.0',
37781cb0ef41Sopenharmony_ci        dependencies: {
37791cb0ef41Sopenharmony_ci          'peer-dep': {
37801cb0ef41Sopenharmony_ci            name: 'peer-dep',
37811cb0ef41Sopenharmony_ci            overridden: false,
37821cb0ef41Sopenharmony_ci            description: 'Peer-dep description here',
37831cb0ef41Sopenharmony_ci            version: '1.0.0',
37841cb0ef41Sopenharmony_ci            _id: 'peer-dep@1.0.0',
37851cb0ef41Sopenharmony_ci            devDependencies: {},
37861cb0ef41Sopenharmony_ci            peerDependencies: {},
37871cb0ef41Sopenharmony_ci            _dependencies: {},
37881cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/peer-dep',
37891cb0ef41Sopenharmony_ci            extraneous: false,
37901cb0ef41Sopenharmony_ci          },
37911cb0ef41Sopenharmony_ci          'dev-dep': {
37921cb0ef41Sopenharmony_ci            name: 'dev-dep',
37931cb0ef41Sopenharmony_ci            overridden: false,
37941cb0ef41Sopenharmony_ci            description: 'A DEV dep kind of dep',
37951cb0ef41Sopenharmony_ci            version: '1.0.0',
37961cb0ef41Sopenharmony_ci            _id: 'dev-dep@1.0.0',
37971cb0ef41Sopenharmony_ci            devDependencies: {},
37981cb0ef41Sopenharmony_ci            peerDependencies: {},
37991cb0ef41Sopenharmony_ci            _dependencies: { foo: '^1.0.0' },
38001cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/dev-dep',
38011cb0ef41Sopenharmony_ci            extraneous: false,
38021cb0ef41Sopenharmony_ci          },
38031cb0ef41Sopenharmony_ci          chai: {
38041cb0ef41Sopenharmony_ci            name: 'chai',
38051cb0ef41Sopenharmony_ci            overridden: false,
38061cb0ef41Sopenharmony_ci            version: '1.0.0',
38071cb0ef41Sopenharmony_ci            _id: 'chai@1.0.0',
38081cb0ef41Sopenharmony_ci            devDependencies: {},
38091cb0ef41Sopenharmony_ci            peerDependencies: {},
38101cb0ef41Sopenharmony_ci            _dependencies: {},
38111cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/chai',
38121cb0ef41Sopenharmony_ci            extraneous: false,
38131cb0ef41Sopenharmony_ci          },
38141cb0ef41Sopenharmony_ci          'optional-dep': {
38151cb0ef41Sopenharmony_ci            name: 'optional-dep',
38161cb0ef41Sopenharmony_ci            overridden: false,
38171cb0ef41Sopenharmony_ci            description: 'Maybe a dep?',
38181cb0ef41Sopenharmony_ci            version: '1.0.0',
38191cb0ef41Sopenharmony_ci            _id: 'optional-dep@1.0.0',
38201cb0ef41Sopenharmony_ci            devDependencies: {},
38211cb0ef41Sopenharmony_ci            peerDependencies: {},
38221cb0ef41Sopenharmony_ci            _dependencies: {},
38231cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/optional-dep',
38241cb0ef41Sopenharmony_ci            extraneous: false,
38251cb0ef41Sopenharmony_ci          },
38261cb0ef41Sopenharmony_ci          'prod-dep': {
38271cb0ef41Sopenharmony_ci            name: 'prod-dep',
38281cb0ef41Sopenharmony_ci            overridden: false,
38291cb0ef41Sopenharmony_ci            description: 'A PROD dep kind of dep',
38301cb0ef41Sopenharmony_ci            version: '1.0.0',
38311cb0ef41Sopenharmony_ci            _id: 'prod-dep@1.0.0',
38321cb0ef41Sopenharmony_ci            devDependencies: {},
38331cb0ef41Sopenharmony_ci            peerDependencies: {},
38341cb0ef41Sopenharmony_ci            _dependencies: { dog: '^2.0.0' },
38351cb0ef41Sopenharmony_ci            path: '{CWD}/prefix/node_modules/prod-dep',
38361cb0ef41Sopenharmony_ci            extraneous: false,
38371cb0ef41Sopenharmony_ci          },
38381cb0ef41Sopenharmony_ci        },
38391cb0ef41Sopenharmony_ci        devDependencies: { 'dev-dep': '^1.0.0' },
38401cb0ef41Sopenharmony_ci        optionalDependencies: { 'optional-dep': '^1.0.0' },
38411cb0ef41Sopenharmony_ci        peerDependencies: { 'peer-dep': '^1.0.0' },
38421cb0ef41Sopenharmony_ci        _id: 'test-npm-ls@1.0.0',
38431cb0ef41Sopenharmony_ci        _dependencies: { 'prod-dep': '^1.0.0', chai: '^1.0.0', 'optional-dep': '^1.0.0' },
38441cb0ef41Sopenharmony_ci        path: '{CWD}/prefix',
38451cb0ef41Sopenharmony_ci        extraneous: false,
38461cb0ef41Sopenharmony_ci      },
38471cb0ef41Sopenharmony_ci      'should output json containing top-level deps in long format'
38481cb0ef41Sopenharmony_ci    )
38491cb0ef41Sopenharmony_ci  })
38501cb0ef41Sopenharmony_ci
38511cb0ef41Sopenharmony_ci  t.test('json read problems', async t => {
38521cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
38531cb0ef41Sopenharmony_ci      config: {
38541cb0ef41Sopenharmony_ci        ...json,
38551cb0ef41Sopenharmony_ci      },
38561cb0ef41Sopenharmony_ci      prefixDir: {
38571cb0ef41Sopenharmony_ci        'package.json': '{broken json',
38581cb0ef41Sopenharmony_ci      },
38591cb0ef41Sopenharmony_ci    })
38601cb0ef41Sopenharmony_ci    await t.rejects(
38611cb0ef41Sopenharmony_ci      ls.exec([]),
38621cb0ef41Sopenharmony_ci      { code: 'EJSONPARSE', message: 'Failed to parse root package.json' },
38631cb0ef41Sopenharmony_ci      'should have missin root package.json msg'
38641cb0ef41Sopenharmony_ci    )
38651cb0ef41Sopenharmony_ci    t.same(
38661cb0ef41Sopenharmony_ci      jsonParse(result()),
38671cb0ef41Sopenharmony_ci      {
38681cb0ef41Sopenharmony_ci        invalid: true,
38691cb0ef41Sopenharmony_ci        problems: [
38701cb0ef41Sopenharmony_ci          'error in {CWD}/prefix: Failed to parse root package.json',
38711cb0ef41Sopenharmony_ci        ],
38721cb0ef41Sopenharmony_ci        error: {
38731cb0ef41Sopenharmony_ci          code: 'EJSONPARSE',
38741cb0ef41Sopenharmony_ci          summary: 'Failed to parse root package.json',
38751cb0ef41Sopenharmony_ci          detail: [
38761cb0ef41Sopenharmony_ci            'Failed to parse JSON data.',
38771cb0ef41Sopenharmony_ci            'Note: package.json must be actual JSON, not just JavaScript.',
38781cb0ef41Sopenharmony_ci          ].join('\n'),
38791cb0ef41Sopenharmony_ci        },
38801cb0ef41Sopenharmony_ci      },
38811cb0ef41Sopenharmony_ci      'should print empty json result'
38821cb0ef41Sopenharmony_ci    )
38831cb0ef41Sopenharmony_ci  })
38841cb0ef41Sopenharmony_ci
38851cb0ef41Sopenharmony_ci  t.test('empty location', async t => {
38861cb0ef41Sopenharmony_ci    const { ls, result } = await mockLs(t, { config: json })
38871cb0ef41Sopenharmony_ci    await ls.exec([])
38881cb0ef41Sopenharmony_ci    t.same(jsonParse(result()), {}, 'should print empty json result')
38891cb0ef41Sopenharmony_ci  })
38901cb0ef41Sopenharmony_ci
38911cb0ef41Sopenharmony_ci  t.test('unmet peer dep', async t => {
38921cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
38931cb0ef41Sopenharmony_ci      config: {
38941cb0ef41Sopenharmony_ci        ...json,
38951cb0ef41Sopenharmony_ci      },
38961cb0ef41Sopenharmony_ci      prefixDir: {
38971cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
38981cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
38991cb0ef41Sopenharmony_ci          version: '1.0.0',
39001cb0ef41Sopenharmony_ci          dependencies: {
39011cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
39021cb0ef41Sopenharmony_ci            chai: '^1.0.0',
39031cb0ef41Sopenharmony_ci          },
39041cb0ef41Sopenharmony_ci          devDependencies: {
39051cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
39061cb0ef41Sopenharmony_ci          },
39071cb0ef41Sopenharmony_ci          optionalDependencies: {
39081cb0ef41Sopenharmony_ci            'optional-dep': '^1.0.0',
39091cb0ef41Sopenharmony_ci          },
39101cb0ef41Sopenharmony_ci          peerDependencies: {
39111cb0ef41Sopenharmony_ci            'peer-dep': '^2.0.0', // mismatching version #
39121cb0ef41Sopenharmony_ci          },
39131cb0ef41Sopenharmony_ci        }),
39141cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
39151cb0ef41Sopenharmony_ci      },
39161cb0ef41Sopenharmony_ci    })
39171cb0ef41Sopenharmony_ci    await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' }, 'Should have ELSPROBLEMS error code')
39181cb0ef41Sopenharmony_ci    t.same(
39191cb0ef41Sopenharmony_ci      jsonParse(result()),
39201cb0ef41Sopenharmony_ci      {
39211cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
39221cb0ef41Sopenharmony_ci        version: '1.0.0',
39231cb0ef41Sopenharmony_ci        problems: [
39241cb0ef41Sopenharmony_ci          'invalid: peer-dep@1.0.0 {CWD}/prefix/node_modules/peer-dep',
39251cb0ef41Sopenharmony_ci        ],
39261cb0ef41Sopenharmony_ci        dependencies: {
39271cb0ef41Sopenharmony_ci          'peer-dep': {
39281cb0ef41Sopenharmony_ci            version: '1.0.0',
39291cb0ef41Sopenharmony_ci            invalid: '"^2.0.0" from the root project',
39301cb0ef41Sopenharmony_ci            overridden: false,
39311cb0ef41Sopenharmony_ci            problems: [
39321cb0ef41Sopenharmony_ci              'invalid: peer-dep@1.0.0 {CWD}/prefix/node_modules/peer-dep',
39331cb0ef41Sopenharmony_ci            ],
39341cb0ef41Sopenharmony_ci          },
39351cb0ef41Sopenharmony_ci          'dev-dep': {
39361cb0ef41Sopenharmony_ci            version: '1.0.0',
39371cb0ef41Sopenharmony_ci            overridden: false,
39381cb0ef41Sopenharmony_ci            dependencies: {
39391cb0ef41Sopenharmony_ci              foo: {
39401cb0ef41Sopenharmony_ci                version: '1.0.0',
39411cb0ef41Sopenharmony_ci                overridden: false,
39421cb0ef41Sopenharmony_ci                dependencies: {
39431cb0ef41Sopenharmony_ci                  dog: {
39441cb0ef41Sopenharmony_ci                    version: '1.0.0',
39451cb0ef41Sopenharmony_ci                    overridden: false,
39461cb0ef41Sopenharmony_ci                  },
39471cb0ef41Sopenharmony_ci                },
39481cb0ef41Sopenharmony_ci              },
39491cb0ef41Sopenharmony_ci            },
39501cb0ef41Sopenharmony_ci          },
39511cb0ef41Sopenharmony_ci          chai: {
39521cb0ef41Sopenharmony_ci            version: '1.0.0',
39531cb0ef41Sopenharmony_ci            overridden: false,
39541cb0ef41Sopenharmony_ci          },
39551cb0ef41Sopenharmony_ci          'optional-dep': {
39561cb0ef41Sopenharmony_ci            version: '1.0.0',
39571cb0ef41Sopenharmony_ci            overridden: false,
39581cb0ef41Sopenharmony_ci          },
39591cb0ef41Sopenharmony_ci          'prod-dep': {
39601cb0ef41Sopenharmony_ci            version: '1.0.0',
39611cb0ef41Sopenharmony_ci            overridden: false,
39621cb0ef41Sopenharmony_ci            dependencies: {
39631cb0ef41Sopenharmony_ci              dog: {
39641cb0ef41Sopenharmony_ci                version: '2.0.0',
39651cb0ef41Sopenharmony_ci                overridden: false,
39661cb0ef41Sopenharmony_ci              },
39671cb0ef41Sopenharmony_ci            },
39681cb0ef41Sopenharmony_ci          },
39691cb0ef41Sopenharmony_ci        },
39701cb0ef41Sopenharmony_ci        error: {
39711cb0ef41Sopenharmony_ci          code: 'ELSPROBLEMS',
39721cb0ef41Sopenharmony_ci          summary: 'invalid: peer-dep@1.0.0 {CWD}/prefix/node_modules/peer-dep',
39731cb0ef41Sopenharmony_ci          detail: '',
39741cb0ef41Sopenharmony_ci        },
39751cb0ef41Sopenharmony_ci      },
39761cb0ef41Sopenharmony_ci      'should output json signaling missing peer dep in problems'
39771cb0ef41Sopenharmony_ci    )
39781cb0ef41Sopenharmony_ci  })
39791cb0ef41Sopenharmony_ci
39801cb0ef41Sopenharmony_ci  t.test('unmet optional dep', async t => {
39811cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
39821cb0ef41Sopenharmony_ci      config: {
39831cb0ef41Sopenharmony_ci        ...json,
39841cb0ef41Sopenharmony_ci      },
39851cb0ef41Sopenharmony_ci      prefixDir: {
39861cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
39871cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
39881cb0ef41Sopenharmony_ci          version: '1.0.0',
39891cb0ef41Sopenharmony_ci          dependencies: {
39901cb0ef41Sopenharmony_ci            'prod-dep': '^1.0.0',
39911cb0ef41Sopenharmony_ci            chai: '^1.0.0',
39921cb0ef41Sopenharmony_ci          },
39931cb0ef41Sopenharmony_ci          devDependencies: {
39941cb0ef41Sopenharmony_ci            'dev-dep': '^1.0.0',
39951cb0ef41Sopenharmony_ci          },
39961cb0ef41Sopenharmony_ci          optionalDependencies: {
39971cb0ef41Sopenharmony_ci            'missing-optional-dep': '^1.0.0',
39981cb0ef41Sopenharmony_ci            'optional-dep': '^2.0.0', // mismatching version #
39991cb0ef41Sopenharmony_ci          },
40001cb0ef41Sopenharmony_ci          peerDependencies: {
40011cb0ef41Sopenharmony_ci            'peer-dep': '^1.0.0',
40021cb0ef41Sopenharmony_ci          },
40031cb0ef41Sopenharmony_ci        }),
40041cb0ef41Sopenharmony_ci        ...diffDepTypesNmFixture,
40051cb0ef41Sopenharmony_ci      },
40061cb0ef41Sopenharmony_ci    })
40071cb0ef41Sopenharmony_ci    await t.rejects(
40081cb0ef41Sopenharmony_ci      ls.exec([]),
40091cb0ef41Sopenharmony_ci      { code: 'ELSPROBLEMS', message: /invalid: optional-dep@1.0.0/ },
40101cb0ef41Sopenharmony_ci      'should have invalid dep error msg'
40111cb0ef41Sopenharmony_ci    )
40121cb0ef41Sopenharmony_ci    t.same(
40131cb0ef41Sopenharmony_ci      jsonParse(result()),
40141cb0ef41Sopenharmony_ci      {
40151cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
40161cb0ef41Sopenharmony_ci        version: '1.0.0',
40171cb0ef41Sopenharmony_ci        problems: [
40181cb0ef41Sopenharmony_ci          // mismatching optional deps get flagged in problems
40191cb0ef41Sopenharmony_ci          'invalid: optional-dep@1.0.0 {CWD}/prefix/node_modules/optional-dep',
40201cb0ef41Sopenharmony_ci        ],
40211cb0ef41Sopenharmony_ci        dependencies: {
40221cb0ef41Sopenharmony_ci          'optional-dep': {
40231cb0ef41Sopenharmony_ci            version: '1.0.0',
40241cb0ef41Sopenharmony_ci            invalid: '"^2.0.0" from the root project',
40251cb0ef41Sopenharmony_ci            overridden: false,
40261cb0ef41Sopenharmony_ci            problems: [
40271cb0ef41Sopenharmony_ci              'invalid: optional-dep@1.0.0 {CWD}/prefix/node_modules/optional-dep',
40281cb0ef41Sopenharmony_ci            ],
40291cb0ef41Sopenharmony_ci          },
40301cb0ef41Sopenharmony_ci          'peer-dep': {
40311cb0ef41Sopenharmony_ci            version: '1.0.0',
40321cb0ef41Sopenharmony_ci            overridden: false,
40331cb0ef41Sopenharmony_ci          },
40341cb0ef41Sopenharmony_ci          'dev-dep': {
40351cb0ef41Sopenharmony_ci            version: '1.0.0',
40361cb0ef41Sopenharmony_ci            overridden: false,
40371cb0ef41Sopenharmony_ci            dependencies: {
40381cb0ef41Sopenharmony_ci              foo: {
40391cb0ef41Sopenharmony_ci                version: '1.0.0',
40401cb0ef41Sopenharmony_ci                overridden: false,
40411cb0ef41Sopenharmony_ci                dependencies: {
40421cb0ef41Sopenharmony_ci                  dog: {
40431cb0ef41Sopenharmony_ci                    version: '1.0.0',
40441cb0ef41Sopenharmony_ci                    overridden: false,
40451cb0ef41Sopenharmony_ci                  },
40461cb0ef41Sopenharmony_ci                },
40471cb0ef41Sopenharmony_ci              },
40481cb0ef41Sopenharmony_ci            },
40491cb0ef41Sopenharmony_ci          },
40501cb0ef41Sopenharmony_ci          chai: {
40511cb0ef41Sopenharmony_ci            version: '1.0.0',
40521cb0ef41Sopenharmony_ci            overridden: false,
40531cb0ef41Sopenharmony_ci          },
40541cb0ef41Sopenharmony_ci          'prod-dep': {
40551cb0ef41Sopenharmony_ci            version: '1.0.0',
40561cb0ef41Sopenharmony_ci            overridden: false,
40571cb0ef41Sopenharmony_ci            dependencies: {
40581cb0ef41Sopenharmony_ci              dog: {
40591cb0ef41Sopenharmony_ci                version: '2.0.0',
40601cb0ef41Sopenharmony_ci                overridden: false,
40611cb0ef41Sopenharmony_ci              },
40621cb0ef41Sopenharmony_ci            },
40631cb0ef41Sopenharmony_ci          },
40641cb0ef41Sopenharmony_ci          'missing-optional-dep': {}, // missing optional dep has an empty entry in json output
40651cb0ef41Sopenharmony_ci        },
40661cb0ef41Sopenharmony_ci        error: {
40671cb0ef41Sopenharmony_ci          code: 'ELSPROBLEMS',
40681cb0ef41Sopenharmony_ci          summary: 'invalid: optional-dep@1.0.0 {CWD}/prefix/node_modules/optional-dep',
40691cb0ef41Sopenharmony_ci          detail: '',
40701cb0ef41Sopenharmony_ci        },
40711cb0ef41Sopenharmony_ci      },
40721cb0ef41Sopenharmony_ci      'should output json with empty entry for missing optional deps'
40731cb0ef41Sopenharmony_ci    )
40741cb0ef41Sopenharmony_ci  })
40751cb0ef41Sopenharmony_ci
40761cb0ef41Sopenharmony_ci  t.test('cycle deps', async t => {
40771cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
40781cb0ef41Sopenharmony_ci      config: {
40791cb0ef41Sopenharmony_ci        ...json,
40801cb0ef41Sopenharmony_ci      },
40811cb0ef41Sopenharmony_ci      prefixDir: {
40821cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
40831cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
40841cb0ef41Sopenharmony_ci          version: '1.0.0',
40851cb0ef41Sopenharmony_ci          dependencies: {
40861cb0ef41Sopenharmony_ci            a: '^1.0.0',
40871cb0ef41Sopenharmony_ci          },
40881cb0ef41Sopenharmony_ci        }),
40891cb0ef41Sopenharmony_ci        node_modules: {
40901cb0ef41Sopenharmony_ci          a: {
40911cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
40921cb0ef41Sopenharmony_ci              name: 'a',
40931cb0ef41Sopenharmony_ci              version: '1.0.0',
40941cb0ef41Sopenharmony_ci              dependencies: {
40951cb0ef41Sopenharmony_ci                b: '^1.0.0',
40961cb0ef41Sopenharmony_ci              },
40971cb0ef41Sopenharmony_ci            }),
40981cb0ef41Sopenharmony_ci          },
40991cb0ef41Sopenharmony_ci          b: {
41001cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
41011cb0ef41Sopenharmony_ci              name: 'b',
41021cb0ef41Sopenharmony_ci              version: '1.0.0',
41031cb0ef41Sopenharmony_ci              dependencies: {
41041cb0ef41Sopenharmony_ci                a: '^1.0.0',
41051cb0ef41Sopenharmony_ci              },
41061cb0ef41Sopenharmony_ci            }),
41071cb0ef41Sopenharmony_ci          },
41081cb0ef41Sopenharmony_ci        },
41091cb0ef41Sopenharmony_ci      },
41101cb0ef41Sopenharmony_ci    })
41111cb0ef41Sopenharmony_ci    await ls.exec([])
41121cb0ef41Sopenharmony_ci    t.same(
41131cb0ef41Sopenharmony_ci      jsonParse(result()),
41141cb0ef41Sopenharmony_ci      {
41151cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
41161cb0ef41Sopenharmony_ci        version: '1.0.0',
41171cb0ef41Sopenharmony_ci        dependencies: {
41181cb0ef41Sopenharmony_ci          a: {
41191cb0ef41Sopenharmony_ci            version: '1.0.0',
41201cb0ef41Sopenharmony_ci            overridden: false,
41211cb0ef41Sopenharmony_ci            dependencies: {
41221cb0ef41Sopenharmony_ci              b: {
41231cb0ef41Sopenharmony_ci                version: '1.0.0',
41241cb0ef41Sopenharmony_ci                overridden: false,
41251cb0ef41Sopenharmony_ci                dependencies: {
41261cb0ef41Sopenharmony_ci                  a: {
41271cb0ef41Sopenharmony_ci                    version: '1.0.0',
41281cb0ef41Sopenharmony_ci                  },
41291cb0ef41Sopenharmony_ci                },
41301cb0ef41Sopenharmony_ci              },
41311cb0ef41Sopenharmony_ci            },
41321cb0ef41Sopenharmony_ci          },
41331cb0ef41Sopenharmony_ci        },
41341cb0ef41Sopenharmony_ci      },
41351cb0ef41Sopenharmony_ci      'should print json output containing deduped ref'
41361cb0ef41Sopenharmony_ci    )
41371cb0ef41Sopenharmony_ci  })
41381cb0ef41Sopenharmony_ci
41391cb0ef41Sopenharmony_ci  t.test('using aliases', async t => {
41401cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
41411cb0ef41Sopenharmony_ci      config: {
41421cb0ef41Sopenharmony_ci        ...json,
41431cb0ef41Sopenharmony_ci      },
41441cb0ef41Sopenharmony_ci      prefixDir: {
41451cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
41461cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
41471cb0ef41Sopenharmony_ci          version: '1.0.0',
41481cb0ef41Sopenharmony_ci          dependencies: {
41491cb0ef41Sopenharmony_ci            a: 'npm:b@1.0.0',
41501cb0ef41Sopenharmony_ci          },
41511cb0ef41Sopenharmony_ci        }),
41521cb0ef41Sopenharmony_ci        node_modules: {
41531cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
41541cb0ef41Sopenharmony_ci            packages: {
41551cb0ef41Sopenharmony_ci              'node_modules/a': {
41561cb0ef41Sopenharmony_ci                name: 'b',
41571cb0ef41Sopenharmony_ci                version: '1.0.0',
41581cb0ef41Sopenharmony_ci                from: 'a@npm:b',
41591cb0ef41Sopenharmony_ci                resolved: 'https://localhost:8080/abbrev/-/abbrev-1.1.1.tgz',
41601cb0ef41Sopenharmony_ci                requested: {
41611cb0ef41Sopenharmony_ci                  type: 'alias',
41621cb0ef41Sopenharmony_ci                },
41631cb0ef41Sopenharmony_ci              },
41641cb0ef41Sopenharmony_ci            },
41651cb0ef41Sopenharmony_ci          }),
41661cb0ef41Sopenharmony_ci          a: {
41671cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
41681cb0ef41Sopenharmony_ci              name: 'b',
41691cb0ef41Sopenharmony_ci              version: '1.0.0',
41701cb0ef41Sopenharmony_ci            }),
41711cb0ef41Sopenharmony_ci          },
41721cb0ef41Sopenharmony_ci        },
41731cb0ef41Sopenharmony_ci      },
41741cb0ef41Sopenharmony_ci    })
41751cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
41761cb0ef41Sopenharmony_ci    await ls.exec([])
41771cb0ef41Sopenharmony_ci    t.same(
41781cb0ef41Sopenharmony_ci      jsonParse(result()),
41791cb0ef41Sopenharmony_ci      {
41801cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
41811cb0ef41Sopenharmony_ci        version: '1.0.0',
41821cb0ef41Sopenharmony_ci        dependencies: {
41831cb0ef41Sopenharmony_ci          a: {
41841cb0ef41Sopenharmony_ci            version: '1.0.0',
41851cb0ef41Sopenharmony_ci            overridden: false,
41861cb0ef41Sopenharmony_ci            resolved: 'https://localhost:8080/abbrev/-/abbrev-1.1.1.tgz',
41871cb0ef41Sopenharmony_ci          },
41881cb0ef41Sopenharmony_ci        },
41891cb0ef41Sopenharmony_ci      },
41901cb0ef41Sopenharmony_ci      'should output json containing aliases'
41911cb0ef41Sopenharmony_ci    )
41921cb0ef41Sopenharmony_ci  })
41931cb0ef41Sopenharmony_ci
41941cb0ef41Sopenharmony_ci  t.test('resolved points to git ref', async t => {
41951cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
41961cb0ef41Sopenharmony_ci      config: {
41971cb0ef41Sopenharmony_ci        ...json,
41981cb0ef41Sopenharmony_ci      },
41991cb0ef41Sopenharmony_ci      prefixDir: {
42001cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
42011cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
42021cb0ef41Sopenharmony_ci          version: '1.0.0',
42031cb0ef41Sopenharmony_ci          dependencies: {
42041cb0ef41Sopenharmony_ci            abbrev: 'git+https://github.com/isaacs/abbrev-js.git',
42051cb0ef41Sopenharmony_ci          },
42061cb0ef41Sopenharmony_ci        }),
42071cb0ef41Sopenharmony_ci        node_modules: {
42081cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
42091cb0ef41Sopenharmony_ci            packages: {
42101cb0ef41Sopenharmony_ci              'node_modules/abbrev': {
42111cb0ef41Sopenharmony_ci                name: 'abbrev',
42121cb0ef41Sopenharmony_ci                version: '1.1.1',
42131cb0ef41Sopenharmony_ci                id: 'abbrev@1.1.1',
42141cb0ef41Sopenharmony_ci                from: 'git+https://github.com/isaacs/abbrev-js.git',
42151cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
42161cb0ef41Sopenharmony_ci                resolved: 'git+https://github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
42171cb0ef41Sopenharmony_ci              },
42181cb0ef41Sopenharmony_ci            },
42191cb0ef41Sopenharmony_ci          }),
42201cb0ef41Sopenharmony_ci          abbrev: {
42211cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
42221cb0ef41Sopenharmony_ci              name: 'abbrev',
42231cb0ef41Sopenharmony_ci              version: '1.1.1',
42241cb0ef41Sopenharmony_ci              _id: 'abbrev@1.1.1',
42251cb0ef41Sopenharmony_ci              _from: 'git+https://github.com/isaacs/abbrev-js.git',
42261cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
42271cb0ef41Sopenharmony_ci              _resolved: 'git+https://github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
42281cb0ef41Sopenharmony_ci              _requested: {
42291cb0ef41Sopenharmony_ci                type: 'git',
42301cb0ef41Sopenharmony_ci                raw: 'git+https:github.com/isaacs/abbrev-js.git',
42311cb0ef41Sopenharmony_ci                rawSpec: 'git+https:github.com/isaacs/abbrev-js.git',
42321cb0ef41Sopenharmony_ci                saveSpec: 'git+https://github.com/isaacs/abbrev-js.git',
42331cb0ef41Sopenharmony_ci                fetchSpec: 'https://github.com/isaacs/abbrev-js.git',
42341cb0ef41Sopenharmony_ci                gitCommittish: null,
42351cb0ef41Sopenharmony_ci              },
42361cb0ef41Sopenharmony_ci            }),
42371cb0ef41Sopenharmony_ci          },
42381cb0ef41Sopenharmony_ci        },
42391cb0ef41Sopenharmony_ci      },
42401cb0ef41Sopenharmony_ci    })
42411cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
42421cb0ef41Sopenharmony_ci    await ls.exec([])
42431cb0ef41Sopenharmony_ci    t.same(
42441cb0ef41Sopenharmony_ci      jsonParse(result()),
42451cb0ef41Sopenharmony_ci      {
42461cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
42471cb0ef41Sopenharmony_ci        version: '1.0.0',
42481cb0ef41Sopenharmony_ci        dependencies: {
42491cb0ef41Sopenharmony_ci          abbrev: {
42501cb0ef41Sopenharmony_ci            version: '1.1.1',
42511cb0ef41Sopenharmony_ci            overridden: false,
42521cb0ef41Sopenharmony_ci            /* eslint-disable-next-line max-len */
42531cb0ef41Sopenharmony_ci            resolved: 'git+ssh://git@github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
42541cb0ef41Sopenharmony_ci          },
42551cb0ef41Sopenharmony_ci        },
42561cb0ef41Sopenharmony_ci      },
42571cb0ef41Sopenharmony_ci      'should output json containing git refs'
42581cb0ef41Sopenharmony_ci    )
42591cb0ef41Sopenharmony_ci  })
42601cb0ef41Sopenharmony_ci
42611cb0ef41Sopenharmony_ci  t.test('from and resolved properties', async t => {
42621cb0ef41Sopenharmony_ci    const { npm, result, ls } = await mockLs(t, {
42631cb0ef41Sopenharmony_ci      config: {
42641cb0ef41Sopenharmony_ci        ...json,
42651cb0ef41Sopenharmony_ci      },
42661cb0ef41Sopenharmony_ci      prefixDir: {
42671cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
42681cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
42691cb0ef41Sopenharmony_ci          version: '1.0.0',
42701cb0ef41Sopenharmony_ci          dependencies: {
42711cb0ef41Sopenharmony_ci            'simple-output': '^2.0.0',
42721cb0ef41Sopenharmony_ci          },
42731cb0ef41Sopenharmony_ci        }),
42741cb0ef41Sopenharmony_ci        node_modules: {
42751cb0ef41Sopenharmony_ci          '.package-lock.json': JSON.stringify({
42761cb0ef41Sopenharmony_ci            packages: {
42771cb0ef41Sopenharmony_ci              'node_modules/simple-output': {
42781cb0ef41Sopenharmony_ci                name: 'simple-output',
42791cb0ef41Sopenharmony_ci                version: '2.1.1',
42801cb0ef41Sopenharmony_ci                _from: 'simple-output',
42811cb0ef41Sopenharmony_ci                _id: 'simple-output@2.1.1',
42821cb0ef41Sopenharmony_ci                _resolved: 'https://registry.npmjs.org/simple-output/-/simple-output-2.1.1.tgz',
42831cb0ef41Sopenharmony_ci                _requested: {
42841cb0ef41Sopenharmony_ci                  type: 'tag',
42851cb0ef41Sopenharmony_ci                  registry: true,
42861cb0ef41Sopenharmony_ci                  raw: 'simple-output',
42871cb0ef41Sopenharmony_ci                  name: 'simple-output',
42881cb0ef41Sopenharmony_ci                  escapedName: 'simple-output',
42891cb0ef41Sopenharmony_ci                  rawSpec: '',
42901cb0ef41Sopenharmony_ci                  saveSpec: null,
42911cb0ef41Sopenharmony_ci                  fetchSpec: 'latest',
42921cb0ef41Sopenharmony_ci                },
42931cb0ef41Sopenharmony_ci                _requiredBy: ['#USER', '/'],
42941cb0ef41Sopenharmony_ci                _shasum: '3c07708ec9ef3e3c985cf0ddd67df09ab8ec2abc',
42951cb0ef41Sopenharmony_ci                _spec: 'simple-output',
42961cb0ef41Sopenharmony_ci              },
42971cb0ef41Sopenharmony_ci            },
42981cb0ef41Sopenharmony_ci          }),
42991cb0ef41Sopenharmony_ci          'simple-output': {
43001cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
43011cb0ef41Sopenharmony_ci              name: 'simple-output',
43021cb0ef41Sopenharmony_ci              version: '2.1.1',
43031cb0ef41Sopenharmony_ci              _from: 'simple-output',
43041cb0ef41Sopenharmony_ci              _id: 'simple-output@2.1.1',
43051cb0ef41Sopenharmony_ci              _resolved: 'https://registry.npmjs.org/simple-output/-/simple-output-2.1.1.tgz',
43061cb0ef41Sopenharmony_ci              _requested: {
43071cb0ef41Sopenharmony_ci                type: 'tag',
43081cb0ef41Sopenharmony_ci                registry: true,
43091cb0ef41Sopenharmony_ci                raw: 'simple-output',
43101cb0ef41Sopenharmony_ci                name: 'simple-output',
43111cb0ef41Sopenharmony_ci                escapedName: 'simple-output',
43121cb0ef41Sopenharmony_ci                rawSpec: '',
43131cb0ef41Sopenharmony_ci                saveSpec: null,
43141cb0ef41Sopenharmony_ci                fetchSpec: 'latest',
43151cb0ef41Sopenharmony_ci              },
43161cb0ef41Sopenharmony_ci              _requiredBy: ['#USER', '/'],
43171cb0ef41Sopenharmony_ci              _shasum: '3c07708ec9ef3e3c985cf0ddd67df09ab8ec2abc',
43181cb0ef41Sopenharmony_ci              _spec: 'simple-output',
43191cb0ef41Sopenharmony_ci            }),
43201cb0ef41Sopenharmony_ci          },
43211cb0ef41Sopenharmony_ci        },
43221cb0ef41Sopenharmony_ci      },
43231cb0ef41Sopenharmony_ci    })
43241cb0ef41Sopenharmony_ci    touchHiddenPackageLock(npm.prefix)
43251cb0ef41Sopenharmony_ci    await ls.exec([])
43261cb0ef41Sopenharmony_ci    t.same(
43271cb0ef41Sopenharmony_ci      jsonParse(result()),
43281cb0ef41Sopenharmony_ci      {
43291cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
43301cb0ef41Sopenharmony_ci        version: '1.0.0',
43311cb0ef41Sopenharmony_ci        dependencies: {
43321cb0ef41Sopenharmony_ci          'simple-output': {
43331cb0ef41Sopenharmony_ci            version: '2.1.1',
43341cb0ef41Sopenharmony_ci            overridden: false,
43351cb0ef41Sopenharmony_ci            resolved: 'https://registry.npmjs.org/simple-output/-/simple-output-2.1.1.tgz',
43361cb0ef41Sopenharmony_ci          },
43371cb0ef41Sopenharmony_ci        },
43381cb0ef41Sopenharmony_ci      },
43391cb0ef41Sopenharmony_ci      'should be printed in json output'
43401cb0ef41Sopenharmony_ci    )
43411cb0ef41Sopenharmony_ci  })
43421cb0ef41Sopenharmony_ci
43431cb0ef41Sopenharmony_ci  t.test('node.name fallback if missing root package name', async t => {
43441cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
43451cb0ef41Sopenharmony_ci      config: {
43461cb0ef41Sopenharmony_ci        ...json,
43471cb0ef41Sopenharmony_ci      },
43481cb0ef41Sopenharmony_ci      prefixDir: {
43491cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
43501cb0ef41Sopenharmony_ci          version: '1.0.0',
43511cb0ef41Sopenharmony_ci        }),
43521cb0ef41Sopenharmony_ci      },
43531cb0ef41Sopenharmony_ci    })
43541cb0ef41Sopenharmony_ci    await ls.exec([])
43551cb0ef41Sopenharmony_ci    t.same(
43561cb0ef41Sopenharmony_ci      jsonParse(result()),
43571cb0ef41Sopenharmony_ci      {
43581cb0ef41Sopenharmony_ci        version: '1.0.0',
43591cb0ef41Sopenharmony_ci        name: 'prefix',
43601cb0ef41Sopenharmony_ci      },
43611cb0ef41Sopenharmony_ci      'should use node.name as key in json result obj'
43621cb0ef41Sopenharmony_ci    )
43631cb0ef41Sopenharmony_ci  })
43641cb0ef41Sopenharmony_ci
43651cb0ef41Sopenharmony_ci  t.test('global', async t => {
43661cb0ef41Sopenharmony_ci    const { result, ls } = await mockLs(t, {
43671cb0ef41Sopenharmony_ci      config: {
43681cb0ef41Sopenharmony_ci        ...json,
43691cb0ef41Sopenharmony_ci        global: true,
43701cb0ef41Sopenharmony_ci      },
43711cb0ef41Sopenharmony_ci      globalPrefixDir: {
43721cb0ef41Sopenharmony_ci        node_modules: {
43731cb0ef41Sopenharmony_ci          a: {
43741cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
43751cb0ef41Sopenharmony_ci              name: 'a',
43761cb0ef41Sopenharmony_ci              version: '1.0.0',
43771cb0ef41Sopenharmony_ci            }),
43781cb0ef41Sopenharmony_ci          },
43791cb0ef41Sopenharmony_ci          b: {
43801cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
43811cb0ef41Sopenharmony_ci              name: 'b',
43821cb0ef41Sopenharmony_ci              version: '1.0.0',
43831cb0ef41Sopenharmony_ci            }),
43841cb0ef41Sopenharmony_ci            node_modules: {
43851cb0ef41Sopenharmony_ci              c: {
43861cb0ef41Sopenharmony_ci                'package.json': JSON.stringify({
43871cb0ef41Sopenharmony_ci                  name: 'c',
43881cb0ef41Sopenharmony_ci                  version: '1.0.0',
43891cb0ef41Sopenharmony_ci                }),
43901cb0ef41Sopenharmony_ci              },
43911cb0ef41Sopenharmony_ci            },
43921cb0ef41Sopenharmony_ci          },
43931cb0ef41Sopenharmony_ci        },
43941cb0ef41Sopenharmony_ci      },
43951cb0ef41Sopenharmony_ci    })
43961cb0ef41Sopenharmony_ci
43971cb0ef41Sopenharmony_ci    await ls.exec([])
43981cb0ef41Sopenharmony_ci    t.same(
43991cb0ef41Sopenharmony_ci      jsonParse(result()),
44001cb0ef41Sopenharmony_ci      {
44011cb0ef41Sopenharmony_ci        name: process.platform === 'win32' ? 'global' : 'lib',
44021cb0ef41Sopenharmony_ci        dependencies: {
44031cb0ef41Sopenharmony_ci          a: {
44041cb0ef41Sopenharmony_ci            version: '1.0.0',
44051cb0ef41Sopenharmony_ci            overridden: false,
44061cb0ef41Sopenharmony_ci          },
44071cb0ef41Sopenharmony_ci          b: {
44081cb0ef41Sopenharmony_ci            version: '1.0.0',
44091cb0ef41Sopenharmony_ci            overridden: false,
44101cb0ef41Sopenharmony_ci            dependencies: {
44111cb0ef41Sopenharmony_ci              c: {
44121cb0ef41Sopenharmony_ci                version: '1.0.0',
44131cb0ef41Sopenharmony_ci                overridden: false,
44141cb0ef41Sopenharmony_ci              },
44151cb0ef41Sopenharmony_ci            },
44161cb0ef41Sopenharmony_ci          },
44171cb0ef41Sopenharmony_ci        },
44181cb0ef41Sopenharmony_ci      },
44191cb0ef41Sopenharmony_ci      'should print json output for global deps'
44201cb0ef41Sopenharmony_ci    )
44211cb0ef41Sopenharmony_ci  })
44221cb0ef41Sopenharmony_ci})
44231cb0ef41Sopenharmony_ci
44241cb0ef41Sopenharmony_cit.test('show multiple invalid reasons', async t => {
44251cb0ef41Sopenharmony_ci  const { result, ls } = await mockLs(t, {
44261cb0ef41Sopenharmony_ci    config: {},
44271cb0ef41Sopenharmony_ci    prefixDir: {
44281cb0ef41Sopenharmony_ci      'package.json': JSON.stringify({
44291cb0ef41Sopenharmony_ci        name: 'test-npm-ls',
44301cb0ef41Sopenharmony_ci        version: '1.0.0',
44311cb0ef41Sopenharmony_ci        dependencies: {
44321cb0ef41Sopenharmony_ci          cat: '^2.0.0',
44331cb0ef41Sopenharmony_ci          dog: '^1.2.3',
44341cb0ef41Sopenharmony_ci        },
44351cb0ef41Sopenharmony_ci      }),
44361cb0ef41Sopenharmony_ci      node_modules: {
44371cb0ef41Sopenharmony_ci        cat: {
44381cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
44391cb0ef41Sopenharmony_ci            name: 'cat',
44401cb0ef41Sopenharmony_ci            version: '1.0.0',
44411cb0ef41Sopenharmony_ci            dependencies: {
44421cb0ef41Sopenharmony_ci              dog: '^2.0.0',
44431cb0ef41Sopenharmony_ci            },
44441cb0ef41Sopenharmony_ci          }),
44451cb0ef41Sopenharmony_ci        },
44461cb0ef41Sopenharmony_ci        dog: {
44471cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
44481cb0ef41Sopenharmony_ci            name: 'dog',
44491cb0ef41Sopenharmony_ci            version: '1.0.0',
44501cb0ef41Sopenharmony_ci            dependencies: {
44511cb0ef41Sopenharmony_ci              cat: '',
44521cb0ef41Sopenharmony_ci            },
44531cb0ef41Sopenharmony_ci          }),
44541cb0ef41Sopenharmony_ci        },
44551cb0ef41Sopenharmony_ci        chai: {
44561cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
44571cb0ef41Sopenharmony_ci            name: 'chai',
44581cb0ef41Sopenharmony_ci            version: '1.0.0',
44591cb0ef41Sopenharmony_ci            dependencies: {
44601cb0ef41Sopenharmony_ci              dog: '2.x',
44611cb0ef41Sopenharmony_ci            },
44621cb0ef41Sopenharmony_ci          }),
44631cb0ef41Sopenharmony_ci        },
44641cb0ef41Sopenharmony_ci      },
44651cb0ef41Sopenharmony_ci    },
44661cb0ef41Sopenharmony_ci  })
44671cb0ef41Sopenharmony_ci
44681cb0ef41Sopenharmony_ci  await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' }, 'should list dep problems')
44691cb0ef41Sopenharmony_ci  t.matchSnapshot(cleanCwd(result()), 'ls result')
44701cb0ef41Sopenharmony_ci})
44711cb0ef41Sopenharmony_ci
44721cb0ef41Sopenharmony_cit.test('ls --package-lock-only', async t => {
44731cb0ef41Sopenharmony_ci  const lock = { 'package-lock-only': true }
44741cb0ef41Sopenharmony_ci
44751cb0ef41Sopenharmony_ci  t.test('ls --package-lock-only --json', async t => {
44761cb0ef41Sopenharmony_ci    const json = { json: true }
44771cb0ef41Sopenharmony_ci
44781cb0ef41Sopenharmony_ci    t.test('no args', async t => {
44791cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
44801cb0ef41Sopenharmony_ci        config: {
44811cb0ef41Sopenharmony_ci          ...lock,
44821cb0ef41Sopenharmony_ci          ...json,
44831cb0ef41Sopenharmony_ci        },
44841cb0ef41Sopenharmony_ci        prefixDir: {
44851cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
44861cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
44871cb0ef41Sopenharmony_ci            version: '1.0.0',
44881cb0ef41Sopenharmony_ci            dependencies: {
44891cb0ef41Sopenharmony_ci              foo: '^1.0.0',
44901cb0ef41Sopenharmony_ci              chai: '^1.0.0',
44911cb0ef41Sopenharmony_ci            },
44921cb0ef41Sopenharmony_ci          }),
44931cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
44941cb0ef41Sopenharmony_ci            dependencies: {
44951cb0ef41Sopenharmony_ci              foo: {
44961cb0ef41Sopenharmony_ci                version: '1.0.0',
44971cb0ef41Sopenharmony_ci                requires: {
44981cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
44991cb0ef41Sopenharmony_ci                },
45001cb0ef41Sopenharmony_ci              },
45011cb0ef41Sopenharmony_ci              dog: {
45021cb0ef41Sopenharmony_ci                version: '1.0.0',
45031cb0ef41Sopenharmony_ci              },
45041cb0ef41Sopenharmony_ci              chai: {
45051cb0ef41Sopenharmony_ci                version: '1.0.0',
45061cb0ef41Sopenharmony_ci              },
45071cb0ef41Sopenharmony_ci            },
45081cb0ef41Sopenharmony_ci          }),
45091cb0ef41Sopenharmony_ci        },
45101cb0ef41Sopenharmony_ci      })
45111cb0ef41Sopenharmony_ci      await ls.exec([])
45121cb0ef41Sopenharmony_ci      t.same(
45131cb0ef41Sopenharmony_ci        jsonParse(result()),
45141cb0ef41Sopenharmony_ci        {
45151cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
45161cb0ef41Sopenharmony_ci          version: '1.0.0',
45171cb0ef41Sopenharmony_ci          dependencies: {
45181cb0ef41Sopenharmony_ci            foo: {
45191cb0ef41Sopenharmony_ci              version: '1.0.0',
45201cb0ef41Sopenharmony_ci              overridden: false,
45211cb0ef41Sopenharmony_ci              dependencies: {
45221cb0ef41Sopenharmony_ci                dog: {
45231cb0ef41Sopenharmony_ci                  version: '1.0.0',
45241cb0ef41Sopenharmony_ci                  overridden: false,
45251cb0ef41Sopenharmony_ci                },
45261cb0ef41Sopenharmony_ci              },
45271cb0ef41Sopenharmony_ci            },
45281cb0ef41Sopenharmony_ci            chai: {
45291cb0ef41Sopenharmony_ci              version: '1.0.0',
45301cb0ef41Sopenharmony_ci              overridden: false,
45311cb0ef41Sopenharmony_ci            },
45321cb0ef41Sopenharmony_ci          },
45331cb0ef41Sopenharmony_ci        },
45341cb0ef41Sopenharmony_ci        'should output json representation of dependencies structure'
45351cb0ef41Sopenharmony_ci      )
45361cb0ef41Sopenharmony_ci    })
45371cb0ef41Sopenharmony_ci
45381cb0ef41Sopenharmony_ci    t.test('extraneous deps', async t => {
45391cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
45401cb0ef41Sopenharmony_ci        config: {
45411cb0ef41Sopenharmony_ci          ...lock,
45421cb0ef41Sopenharmony_ci          ...json,
45431cb0ef41Sopenharmony_ci        },
45441cb0ef41Sopenharmony_ci        prefixDir: {
45451cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
45461cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
45471cb0ef41Sopenharmony_ci            version: '1.0.0',
45481cb0ef41Sopenharmony_ci            dependencies: {
45491cb0ef41Sopenharmony_ci              foo: '^1.0.0',
45501cb0ef41Sopenharmony_ci            },
45511cb0ef41Sopenharmony_ci          }),
45521cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
45531cb0ef41Sopenharmony_ci            dependencies: {
45541cb0ef41Sopenharmony_ci              foo: {
45551cb0ef41Sopenharmony_ci                version: '1.0.0',
45561cb0ef41Sopenharmony_ci                requires: {
45571cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
45581cb0ef41Sopenharmony_ci                },
45591cb0ef41Sopenharmony_ci              },
45601cb0ef41Sopenharmony_ci              dog: {
45611cb0ef41Sopenharmony_ci                version: '1.0.0',
45621cb0ef41Sopenharmony_ci              },
45631cb0ef41Sopenharmony_ci              chai: {
45641cb0ef41Sopenharmony_ci                version: '1.0.0',
45651cb0ef41Sopenharmony_ci              },
45661cb0ef41Sopenharmony_ci            },
45671cb0ef41Sopenharmony_ci          }),
45681cb0ef41Sopenharmony_ci        },
45691cb0ef41Sopenharmony_ci      })
45701cb0ef41Sopenharmony_ci      await ls.exec([])
45711cb0ef41Sopenharmony_ci      t.same(
45721cb0ef41Sopenharmony_ci        jsonParse(result()),
45731cb0ef41Sopenharmony_ci        {
45741cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
45751cb0ef41Sopenharmony_ci          version: '1.0.0',
45761cb0ef41Sopenharmony_ci          dependencies: {
45771cb0ef41Sopenharmony_ci            foo: {
45781cb0ef41Sopenharmony_ci              version: '1.0.0',
45791cb0ef41Sopenharmony_ci              overridden: false,
45801cb0ef41Sopenharmony_ci              dependencies: {
45811cb0ef41Sopenharmony_ci                dog: {
45821cb0ef41Sopenharmony_ci                  version: '1.0.0',
45831cb0ef41Sopenharmony_ci                  overridden: false,
45841cb0ef41Sopenharmony_ci                },
45851cb0ef41Sopenharmony_ci              },
45861cb0ef41Sopenharmony_ci            },
45871cb0ef41Sopenharmony_ci          },
45881cb0ef41Sopenharmony_ci        },
45891cb0ef41Sopenharmony_ci        'should output json containing no problem info'
45901cb0ef41Sopenharmony_ci      )
45911cb0ef41Sopenharmony_ci    })
45921cb0ef41Sopenharmony_ci
45931cb0ef41Sopenharmony_ci    t.test('missing deps --long', async t => {
45941cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
45951cb0ef41Sopenharmony_ci        config: {
45961cb0ef41Sopenharmony_ci          ...lock,
45971cb0ef41Sopenharmony_ci          ...json,
45981cb0ef41Sopenharmony_ci          long: true,
45991cb0ef41Sopenharmony_ci        },
46001cb0ef41Sopenharmony_ci        prefixDir: {
46011cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
46021cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
46031cb0ef41Sopenharmony_ci            version: '1.0.0',
46041cb0ef41Sopenharmony_ci            dependencies: {
46051cb0ef41Sopenharmony_ci              foo: '^1.0.0',
46061cb0ef41Sopenharmony_ci              dog: '^1.0.0',
46071cb0ef41Sopenharmony_ci              chai: '^1.0.0',
46081cb0ef41Sopenharmony_ci              ipsum: '^1.0.0',
46091cb0ef41Sopenharmony_ci            },
46101cb0ef41Sopenharmony_ci          }),
46111cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
46121cb0ef41Sopenharmony_ci            dependencies: {
46131cb0ef41Sopenharmony_ci              foo: {
46141cb0ef41Sopenharmony_ci                version: '1.0.0',
46151cb0ef41Sopenharmony_ci                requires: {
46161cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
46171cb0ef41Sopenharmony_ci                },
46181cb0ef41Sopenharmony_ci              },
46191cb0ef41Sopenharmony_ci              dog: {
46201cb0ef41Sopenharmony_ci                version: '1.0.0',
46211cb0ef41Sopenharmony_ci              },
46221cb0ef41Sopenharmony_ci              chai: {
46231cb0ef41Sopenharmony_ci                version: '1.0.0',
46241cb0ef41Sopenharmony_ci              },
46251cb0ef41Sopenharmony_ci              ipsum: {
46261cb0ef41Sopenharmony_ci                version: '1.0.0',
46271cb0ef41Sopenharmony_ci              },
46281cb0ef41Sopenharmony_ci            },
46291cb0ef41Sopenharmony_ci          }),
46301cb0ef41Sopenharmony_ci        },
46311cb0ef41Sopenharmony_ci      })
46321cb0ef41Sopenharmony_ci      await ls.exec([])
46331cb0ef41Sopenharmony_ci      t.match(
46341cb0ef41Sopenharmony_ci        jsonParse(result()),
46351cb0ef41Sopenharmony_ci        {
46361cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
46371cb0ef41Sopenharmony_ci          version: '1.0.0',
46381cb0ef41Sopenharmony_ci        },
46391cb0ef41Sopenharmony_ci        'should output json containing no problems info'
46401cb0ef41Sopenharmony_ci      )
46411cb0ef41Sopenharmony_ci    })
46421cb0ef41Sopenharmony_ci
46431cb0ef41Sopenharmony_ci    t.test('with filter arg', async t => {
46441cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
46451cb0ef41Sopenharmony_ci        config: {
46461cb0ef41Sopenharmony_ci          ...lock,
46471cb0ef41Sopenharmony_ci          ...json,
46481cb0ef41Sopenharmony_ci        },
46491cb0ef41Sopenharmony_ci        prefixDir: {
46501cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
46511cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
46521cb0ef41Sopenharmony_ci            version: '1.0.0',
46531cb0ef41Sopenharmony_ci            dependencies: {
46541cb0ef41Sopenharmony_ci              foo: '^1.0.0',
46551cb0ef41Sopenharmony_ci              chai: '^1.0.0',
46561cb0ef41Sopenharmony_ci            },
46571cb0ef41Sopenharmony_ci          }),
46581cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
46591cb0ef41Sopenharmony_ci            dependencies: {
46601cb0ef41Sopenharmony_ci              foo: {
46611cb0ef41Sopenharmony_ci                version: '1.0.0',
46621cb0ef41Sopenharmony_ci                requires: {
46631cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
46641cb0ef41Sopenharmony_ci                },
46651cb0ef41Sopenharmony_ci              },
46661cb0ef41Sopenharmony_ci              dog: {
46671cb0ef41Sopenharmony_ci                version: '1.0.0',
46681cb0ef41Sopenharmony_ci              },
46691cb0ef41Sopenharmony_ci              chai: {
46701cb0ef41Sopenharmony_ci                version: '1.0.0',
46711cb0ef41Sopenharmony_ci              },
46721cb0ef41Sopenharmony_ci              ipsum: {
46731cb0ef41Sopenharmony_ci                version: '1.0.0',
46741cb0ef41Sopenharmony_ci              },
46751cb0ef41Sopenharmony_ci            },
46761cb0ef41Sopenharmony_ci          }),
46771cb0ef41Sopenharmony_ci        },
46781cb0ef41Sopenharmony_ci      })
46791cb0ef41Sopenharmony_ci      await ls.exec(['chai'])
46801cb0ef41Sopenharmony_ci      t.same(
46811cb0ef41Sopenharmony_ci        jsonParse(result()),
46821cb0ef41Sopenharmony_ci        {
46831cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
46841cb0ef41Sopenharmony_ci          version: '1.0.0',
46851cb0ef41Sopenharmony_ci          dependencies: {
46861cb0ef41Sopenharmony_ci            chai: {
46871cb0ef41Sopenharmony_ci              version: '1.0.0',
46881cb0ef41Sopenharmony_ci              overridden: false,
46891cb0ef41Sopenharmony_ci            },
46901cb0ef41Sopenharmony_ci          },
46911cb0ef41Sopenharmony_ci        },
46921cb0ef41Sopenharmony_ci        'should output json contaning only occurrences of filtered by package'
46931cb0ef41Sopenharmony_ci      )
46941cb0ef41Sopenharmony_ci      t.notOk(process.exitCode, 'should not set exit code')
46951cb0ef41Sopenharmony_ci    })
46961cb0ef41Sopenharmony_ci
46971cb0ef41Sopenharmony_ci    t.test('with filter arg nested dep', async t => {
46981cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
46991cb0ef41Sopenharmony_ci        config: {
47001cb0ef41Sopenharmony_ci          ...lock,
47011cb0ef41Sopenharmony_ci          ...json,
47021cb0ef41Sopenharmony_ci        },
47031cb0ef41Sopenharmony_ci        prefixDir: {
47041cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
47051cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
47061cb0ef41Sopenharmony_ci            version: '1.0.0',
47071cb0ef41Sopenharmony_ci            dependencies: {
47081cb0ef41Sopenharmony_ci              foo: '^1.0.0',
47091cb0ef41Sopenharmony_ci              chai: '^1.0.0',
47101cb0ef41Sopenharmony_ci            },
47111cb0ef41Sopenharmony_ci          }),
47121cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
47131cb0ef41Sopenharmony_ci            dependencies: {
47141cb0ef41Sopenharmony_ci              foo: {
47151cb0ef41Sopenharmony_ci                version: '1.0.0',
47161cb0ef41Sopenharmony_ci                requires: {
47171cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
47181cb0ef41Sopenharmony_ci                },
47191cb0ef41Sopenharmony_ci              },
47201cb0ef41Sopenharmony_ci              dog: {
47211cb0ef41Sopenharmony_ci                version: '1.0.0',
47221cb0ef41Sopenharmony_ci              },
47231cb0ef41Sopenharmony_ci              chai: {
47241cb0ef41Sopenharmony_ci                version: '1.0.0',
47251cb0ef41Sopenharmony_ci              },
47261cb0ef41Sopenharmony_ci              ipsum: {
47271cb0ef41Sopenharmony_ci                version: '1.0.0',
47281cb0ef41Sopenharmony_ci              },
47291cb0ef41Sopenharmony_ci            },
47301cb0ef41Sopenharmony_ci          }),
47311cb0ef41Sopenharmony_ci        },
47321cb0ef41Sopenharmony_ci      })
47331cb0ef41Sopenharmony_ci      await ls.exec(['dog'])
47341cb0ef41Sopenharmony_ci      t.same(
47351cb0ef41Sopenharmony_ci        jsonParse(result()),
47361cb0ef41Sopenharmony_ci        {
47371cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
47381cb0ef41Sopenharmony_ci          version: '1.0.0',
47391cb0ef41Sopenharmony_ci          dependencies: {
47401cb0ef41Sopenharmony_ci            foo: {
47411cb0ef41Sopenharmony_ci              version: '1.0.0',
47421cb0ef41Sopenharmony_ci              overridden: false,
47431cb0ef41Sopenharmony_ci              dependencies: {
47441cb0ef41Sopenharmony_ci                dog: {
47451cb0ef41Sopenharmony_ci                  version: '1.0.0',
47461cb0ef41Sopenharmony_ci                  overridden: false,
47471cb0ef41Sopenharmony_ci                },
47481cb0ef41Sopenharmony_ci              },
47491cb0ef41Sopenharmony_ci            },
47501cb0ef41Sopenharmony_ci          },
47511cb0ef41Sopenharmony_ci        },
47521cb0ef41Sopenharmony_ci        'should output json contaning only occurrences of filtered by package'
47531cb0ef41Sopenharmony_ci      )
47541cb0ef41Sopenharmony_ci    })
47551cb0ef41Sopenharmony_ci
47561cb0ef41Sopenharmony_ci    t.test('with multiple filter args', async t => {
47571cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
47581cb0ef41Sopenharmony_ci        config: {
47591cb0ef41Sopenharmony_ci          ...lock,
47601cb0ef41Sopenharmony_ci          ...json,
47611cb0ef41Sopenharmony_ci        },
47621cb0ef41Sopenharmony_ci        prefixDir: {
47631cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
47641cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
47651cb0ef41Sopenharmony_ci            version: '1.0.0',
47661cb0ef41Sopenharmony_ci            dependencies: {
47671cb0ef41Sopenharmony_ci              foo: '^1.0.0',
47681cb0ef41Sopenharmony_ci              chai: '^1.0.0',
47691cb0ef41Sopenharmony_ci              ipsum: '^1.0.0',
47701cb0ef41Sopenharmony_ci            },
47711cb0ef41Sopenharmony_ci          }),
47721cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
47731cb0ef41Sopenharmony_ci            dependencies: {
47741cb0ef41Sopenharmony_ci              foo: {
47751cb0ef41Sopenharmony_ci                version: '1.0.0',
47761cb0ef41Sopenharmony_ci                requires: {
47771cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
47781cb0ef41Sopenharmony_ci                },
47791cb0ef41Sopenharmony_ci              },
47801cb0ef41Sopenharmony_ci              dog: {
47811cb0ef41Sopenharmony_ci                version: '1.0.0',
47821cb0ef41Sopenharmony_ci              },
47831cb0ef41Sopenharmony_ci              chai: {
47841cb0ef41Sopenharmony_ci                version: '1.0.0',
47851cb0ef41Sopenharmony_ci              },
47861cb0ef41Sopenharmony_ci              ipsum: {
47871cb0ef41Sopenharmony_ci                version: '1.0.0',
47881cb0ef41Sopenharmony_ci              },
47891cb0ef41Sopenharmony_ci            },
47901cb0ef41Sopenharmony_ci          }),
47911cb0ef41Sopenharmony_ci        },
47921cb0ef41Sopenharmony_ci      })
47931cb0ef41Sopenharmony_ci      await ls.exec(['dog@*', 'chai@1.0.0'])
47941cb0ef41Sopenharmony_ci      t.same(
47951cb0ef41Sopenharmony_ci        jsonParse(result()),
47961cb0ef41Sopenharmony_ci        {
47971cb0ef41Sopenharmony_ci          version: '1.0.0',
47981cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
47991cb0ef41Sopenharmony_ci          dependencies: {
48001cb0ef41Sopenharmony_ci            foo: {
48011cb0ef41Sopenharmony_ci              version: '1.0.0',
48021cb0ef41Sopenharmony_ci              overridden: false,
48031cb0ef41Sopenharmony_ci              dependencies: {
48041cb0ef41Sopenharmony_ci                dog: {
48051cb0ef41Sopenharmony_ci                  version: '1.0.0',
48061cb0ef41Sopenharmony_ci                  overridden: false,
48071cb0ef41Sopenharmony_ci                },
48081cb0ef41Sopenharmony_ci              },
48091cb0ef41Sopenharmony_ci            },
48101cb0ef41Sopenharmony_ci            chai: {
48111cb0ef41Sopenharmony_ci              version: '1.0.0',
48121cb0ef41Sopenharmony_ci              overridden: false,
48131cb0ef41Sopenharmony_ci            },
48141cb0ef41Sopenharmony_ci          },
48151cb0ef41Sopenharmony_ci        },
48161cb0ef41Sopenharmony_ci        /* eslint-disable-next-line max-len */
48171cb0ef41Sopenharmony_ci        'should output json contaning only occurrences of multiple filtered packages and their ancestors'
48181cb0ef41Sopenharmony_ci      )
48191cb0ef41Sopenharmony_ci    })
48201cb0ef41Sopenharmony_ci
48211cb0ef41Sopenharmony_ci    t.test('with missing filter arg', async t => {
48221cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
48231cb0ef41Sopenharmony_ci        config: {
48241cb0ef41Sopenharmony_ci          ...lock,
48251cb0ef41Sopenharmony_ci          ...json,
48261cb0ef41Sopenharmony_ci        },
48271cb0ef41Sopenharmony_ci        prefixDir: {
48281cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
48291cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
48301cb0ef41Sopenharmony_ci            version: '1.0.0',
48311cb0ef41Sopenharmony_ci            dependencies: {
48321cb0ef41Sopenharmony_ci              foo: '^1.0.0',
48331cb0ef41Sopenharmony_ci              chai: '^1.0.0',
48341cb0ef41Sopenharmony_ci            },
48351cb0ef41Sopenharmony_ci          }),
48361cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
48371cb0ef41Sopenharmony_ci            dependencies: {
48381cb0ef41Sopenharmony_ci              foo: {
48391cb0ef41Sopenharmony_ci                version: '1.0.0',
48401cb0ef41Sopenharmony_ci                requires: {
48411cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
48421cb0ef41Sopenharmony_ci                },
48431cb0ef41Sopenharmony_ci              },
48441cb0ef41Sopenharmony_ci              dog: {
48451cb0ef41Sopenharmony_ci                version: '1.0.0',
48461cb0ef41Sopenharmony_ci              },
48471cb0ef41Sopenharmony_ci              chai: {
48481cb0ef41Sopenharmony_ci                version: '1.0.0',
48491cb0ef41Sopenharmony_ci              },
48501cb0ef41Sopenharmony_ci            },
48511cb0ef41Sopenharmony_ci          }),
48521cb0ef41Sopenharmony_ci        },
48531cb0ef41Sopenharmony_ci      })
48541cb0ef41Sopenharmony_ci      await ls.exec(['notadep'])
48551cb0ef41Sopenharmony_ci      t.same(
48561cb0ef41Sopenharmony_ci        jsonParse(result()),
48571cb0ef41Sopenharmony_ci        {
48581cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
48591cb0ef41Sopenharmony_ci          version: '1.0.0',
48601cb0ef41Sopenharmony_ci        },
48611cb0ef41Sopenharmony_ci        'should output json containing no dependencies info'
48621cb0ef41Sopenharmony_ci      )
48631cb0ef41Sopenharmony_ci      t.equal(process.exitCode, 1, 'should exit with error code 1')
48641cb0ef41Sopenharmony_ci    })
48651cb0ef41Sopenharmony_ci
48661cb0ef41Sopenharmony_ci    t.test('default --depth value should now be 0', async t => {
48671cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
48681cb0ef41Sopenharmony_ci        config: {
48691cb0ef41Sopenharmony_ci          ...lock,
48701cb0ef41Sopenharmony_ci          ...json,
48711cb0ef41Sopenharmony_ci          all: false,
48721cb0ef41Sopenharmony_ci        },
48731cb0ef41Sopenharmony_ci        prefixDir: {
48741cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
48751cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
48761cb0ef41Sopenharmony_ci            version: '1.0.0',
48771cb0ef41Sopenharmony_ci            dependencies: {
48781cb0ef41Sopenharmony_ci              foo: '^1.0.0',
48791cb0ef41Sopenharmony_ci              chai: '^1.0.0',
48801cb0ef41Sopenharmony_ci            },
48811cb0ef41Sopenharmony_ci          }),
48821cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
48831cb0ef41Sopenharmony_ci            dependencies: {
48841cb0ef41Sopenharmony_ci              foo: {
48851cb0ef41Sopenharmony_ci                version: '1.0.0',
48861cb0ef41Sopenharmony_ci                requires: {
48871cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
48881cb0ef41Sopenharmony_ci                },
48891cb0ef41Sopenharmony_ci              },
48901cb0ef41Sopenharmony_ci              dog: {
48911cb0ef41Sopenharmony_ci                version: '1.0.0',
48921cb0ef41Sopenharmony_ci              },
48931cb0ef41Sopenharmony_ci              chai: {
48941cb0ef41Sopenharmony_ci                version: '1.0.0',
48951cb0ef41Sopenharmony_ci              },
48961cb0ef41Sopenharmony_ci            },
48971cb0ef41Sopenharmony_ci          }),
48981cb0ef41Sopenharmony_ci        },
48991cb0ef41Sopenharmony_ci      })
49001cb0ef41Sopenharmony_ci      await ls.exec([])
49011cb0ef41Sopenharmony_ci      t.same(
49021cb0ef41Sopenharmony_ci        jsonParse(result()),
49031cb0ef41Sopenharmony_ci        {
49041cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
49051cb0ef41Sopenharmony_ci          version: '1.0.0',
49061cb0ef41Sopenharmony_ci          dependencies: {
49071cb0ef41Sopenharmony_ci            foo: {
49081cb0ef41Sopenharmony_ci              version: '1.0.0',
49091cb0ef41Sopenharmony_ci              overridden: false,
49101cb0ef41Sopenharmony_ci            },
49111cb0ef41Sopenharmony_ci            chai: {
49121cb0ef41Sopenharmony_ci              version: '1.0.0',
49131cb0ef41Sopenharmony_ci              overridden: false,
49141cb0ef41Sopenharmony_ci            },
49151cb0ef41Sopenharmony_ci          },
49161cb0ef41Sopenharmony_ci        },
49171cb0ef41Sopenharmony_ci        'should output json containing only top-level dependencies'
49181cb0ef41Sopenharmony_ci      )
49191cb0ef41Sopenharmony_ci    })
49201cb0ef41Sopenharmony_ci
49211cb0ef41Sopenharmony_ci    t.test('--depth=0', async t => {
49221cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
49231cb0ef41Sopenharmony_ci        config: {
49241cb0ef41Sopenharmony_ci          ...lock,
49251cb0ef41Sopenharmony_ci          ...json,
49261cb0ef41Sopenharmony_ci          depth: 0,
49271cb0ef41Sopenharmony_ci          all: false,
49281cb0ef41Sopenharmony_ci        },
49291cb0ef41Sopenharmony_ci        prefixDir: {
49301cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
49311cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
49321cb0ef41Sopenharmony_ci            version: '1.0.0',
49331cb0ef41Sopenharmony_ci            dependencies: {
49341cb0ef41Sopenharmony_ci              foo: '^1.0.0',
49351cb0ef41Sopenharmony_ci              chai: '^1.0.0',
49361cb0ef41Sopenharmony_ci            },
49371cb0ef41Sopenharmony_ci          }),
49381cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
49391cb0ef41Sopenharmony_ci            dependencies: {
49401cb0ef41Sopenharmony_ci              foo: {
49411cb0ef41Sopenharmony_ci                version: '1.0.0',
49421cb0ef41Sopenharmony_ci                requires: {
49431cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
49441cb0ef41Sopenharmony_ci                },
49451cb0ef41Sopenharmony_ci              },
49461cb0ef41Sopenharmony_ci              dog: {
49471cb0ef41Sopenharmony_ci                version: '1.0.0',
49481cb0ef41Sopenharmony_ci              },
49491cb0ef41Sopenharmony_ci              chai: {
49501cb0ef41Sopenharmony_ci                version: '1.0.0',
49511cb0ef41Sopenharmony_ci              },
49521cb0ef41Sopenharmony_ci            },
49531cb0ef41Sopenharmony_ci          }),
49541cb0ef41Sopenharmony_ci        },
49551cb0ef41Sopenharmony_ci      })
49561cb0ef41Sopenharmony_ci      await ls.exec([])
49571cb0ef41Sopenharmony_ci      t.same(
49581cb0ef41Sopenharmony_ci        jsonParse(result()),
49591cb0ef41Sopenharmony_ci        {
49601cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
49611cb0ef41Sopenharmony_ci          version: '1.0.0',
49621cb0ef41Sopenharmony_ci          dependencies: {
49631cb0ef41Sopenharmony_ci            foo: {
49641cb0ef41Sopenharmony_ci              version: '1.0.0',
49651cb0ef41Sopenharmony_ci              overridden: false,
49661cb0ef41Sopenharmony_ci            },
49671cb0ef41Sopenharmony_ci            chai: {
49681cb0ef41Sopenharmony_ci              version: '1.0.0',
49691cb0ef41Sopenharmony_ci              overridden: false,
49701cb0ef41Sopenharmony_ci            },
49711cb0ef41Sopenharmony_ci          },
49721cb0ef41Sopenharmony_ci        },
49731cb0ef41Sopenharmony_ci        'should output json containing only top-level dependencies'
49741cb0ef41Sopenharmony_ci      )
49751cb0ef41Sopenharmony_ci    })
49761cb0ef41Sopenharmony_ci
49771cb0ef41Sopenharmony_ci    t.test('--depth=1', async t => {
49781cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
49791cb0ef41Sopenharmony_ci        config: {
49801cb0ef41Sopenharmony_ci          ...lock,
49811cb0ef41Sopenharmony_ci          ...json,
49821cb0ef41Sopenharmony_ci          all: false,
49831cb0ef41Sopenharmony_ci          depth: 1,
49841cb0ef41Sopenharmony_ci        },
49851cb0ef41Sopenharmony_ci        prefixDir: {
49861cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
49871cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
49881cb0ef41Sopenharmony_ci            version: '1.0.0',
49891cb0ef41Sopenharmony_ci            dependencies: {
49901cb0ef41Sopenharmony_ci              foo: '^1.0.0',
49911cb0ef41Sopenharmony_ci              chai: '^1.0.0',
49921cb0ef41Sopenharmony_ci            },
49931cb0ef41Sopenharmony_ci          }),
49941cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
49951cb0ef41Sopenharmony_ci            dependencies: {
49961cb0ef41Sopenharmony_ci              foo: {
49971cb0ef41Sopenharmony_ci                version: '1.0.0',
49981cb0ef41Sopenharmony_ci                requires: {
49991cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
50001cb0ef41Sopenharmony_ci                },
50011cb0ef41Sopenharmony_ci              },
50021cb0ef41Sopenharmony_ci              dog: {
50031cb0ef41Sopenharmony_ci                version: '1.0.0',
50041cb0ef41Sopenharmony_ci              },
50051cb0ef41Sopenharmony_ci              chai: {
50061cb0ef41Sopenharmony_ci                version: '1.0.0',
50071cb0ef41Sopenharmony_ci              },
50081cb0ef41Sopenharmony_ci            },
50091cb0ef41Sopenharmony_ci          }),
50101cb0ef41Sopenharmony_ci        },
50111cb0ef41Sopenharmony_ci      })
50121cb0ef41Sopenharmony_ci      await ls.exec([])
50131cb0ef41Sopenharmony_ci      t.same(
50141cb0ef41Sopenharmony_ci        jsonParse(result()),
50151cb0ef41Sopenharmony_ci        {
50161cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
50171cb0ef41Sopenharmony_ci          version: '1.0.0',
50181cb0ef41Sopenharmony_ci          dependencies: {
50191cb0ef41Sopenharmony_ci            foo: {
50201cb0ef41Sopenharmony_ci              version: '1.0.0',
50211cb0ef41Sopenharmony_ci              overridden: false,
50221cb0ef41Sopenharmony_ci              dependencies: {
50231cb0ef41Sopenharmony_ci                dog: {
50241cb0ef41Sopenharmony_ci                  version: '1.0.0',
50251cb0ef41Sopenharmony_ci                  overridden: false,
50261cb0ef41Sopenharmony_ci                },
50271cb0ef41Sopenharmony_ci              },
50281cb0ef41Sopenharmony_ci            },
50291cb0ef41Sopenharmony_ci            chai: {
50301cb0ef41Sopenharmony_ci              version: '1.0.0',
50311cb0ef41Sopenharmony_ci              overridden: false,
50321cb0ef41Sopenharmony_ci            },
50331cb0ef41Sopenharmony_ci          },
50341cb0ef41Sopenharmony_ci        },
50351cb0ef41Sopenharmony_ci        'should output json containing top-level deps and their deps only'
50361cb0ef41Sopenharmony_ci      )
50371cb0ef41Sopenharmony_ci    })
50381cb0ef41Sopenharmony_ci
50391cb0ef41Sopenharmony_ci    t.test('missing/invalid/extraneous', async t => {
50401cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
50411cb0ef41Sopenharmony_ci        config: {
50421cb0ef41Sopenharmony_ci          ...lock,
50431cb0ef41Sopenharmony_ci          ...json,
50441cb0ef41Sopenharmony_ci        },
50451cb0ef41Sopenharmony_ci        prefixDir: {
50461cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
50471cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
50481cb0ef41Sopenharmony_ci            version: '1.0.0',
50491cb0ef41Sopenharmony_ci            dependencies: {
50501cb0ef41Sopenharmony_ci              foo: '^2.0.0',
50511cb0ef41Sopenharmony_ci              ipsum: '^1.0.0',
50521cb0ef41Sopenharmony_ci            },
50531cb0ef41Sopenharmony_ci          }),
50541cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
50551cb0ef41Sopenharmony_ci            dependencies: {
50561cb0ef41Sopenharmony_ci              foo: {
50571cb0ef41Sopenharmony_ci                version: '1.0.0',
50581cb0ef41Sopenharmony_ci                requires: {
50591cb0ef41Sopenharmony_ci                  dog: '^1.0.0',
50601cb0ef41Sopenharmony_ci                },
50611cb0ef41Sopenharmony_ci              },
50621cb0ef41Sopenharmony_ci              dog: {
50631cb0ef41Sopenharmony_ci                version: '1.0.0',
50641cb0ef41Sopenharmony_ci              },
50651cb0ef41Sopenharmony_ci              chai: {
50661cb0ef41Sopenharmony_ci                version: '1.0.0',
50671cb0ef41Sopenharmony_ci              },
50681cb0ef41Sopenharmony_ci            },
50691cb0ef41Sopenharmony_ci          }),
50701cb0ef41Sopenharmony_ci        },
50711cb0ef41Sopenharmony_ci      })
50721cb0ef41Sopenharmony_ci      await t.rejects(ls.exec([]), { code: 'ELSPROBLEMS' }, 'should list dep problems')
50731cb0ef41Sopenharmony_ci      t.same(
50741cb0ef41Sopenharmony_ci        jsonParse(result()),
50751cb0ef41Sopenharmony_ci        {
50761cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
50771cb0ef41Sopenharmony_ci          version: '1.0.0',
50781cb0ef41Sopenharmony_ci          problems: [
50791cb0ef41Sopenharmony_ci            'invalid: foo@1.0.0 {CWD}/prefix/node_modules/foo',
50801cb0ef41Sopenharmony_ci            'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0',
50811cb0ef41Sopenharmony_ci          ],
50821cb0ef41Sopenharmony_ci          dependencies: {
50831cb0ef41Sopenharmony_ci            foo: {
50841cb0ef41Sopenharmony_ci              version: '1.0.0',
50851cb0ef41Sopenharmony_ci              overridden: false,
50861cb0ef41Sopenharmony_ci              invalid: '"^2.0.0" from the root project',
50871cb0ef41Sopenharmony_ci              problems: [
50881cb0ef41Sopenharmony_ci                'invalid: foo@1.0.0 {CWD}/prefix/node_modules/foo',
50891cb0ef41Sopenharmony_ci              ],
50901cb0ef41Sopenharmony_ci              dependencies: {
50911cb0ef41Sopenharmony_ci                dog: {
50921cb0ef41Sopenharmony_ci                  version: '1.0.0',
50931cb0ef41Sopenharmony_ci                  overridden: false,
50941cb0ef41Sopenharmony_ci                },
50951cb0ef41Sopenharmony_ci              },
50961cb0ef41Sopenharmony_ci            },
50971cb0ef41Sopenharmony_ci            ipsum: {
50981cb0ef41Sopenharmony_ci              required: '^1.0.0',
50991cb0ef41Sopenharmony_ci              missing: true,
51001cb0ef41Sopenharmony_ci              problems: ['missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0'],
51011cb0ef41Sopenharmony_ci            },
51021cb0ef41Sopenharmony_ci          },
51031cb0ef41Sopenharmony_ci          error: {
51041cb0ef41Sopenharmony_ci            code: 'ELSPROBLEMS',
51051cb0ef41Sopenharmony_ci            summary: [
51061cb0ef41Sopenharmony_ci              'invalid: foo@1.0.0 {CWD}/prefix/node_modules/foo',
51071cb0ef41Sopenharmony_ci              'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0',
51081cb0ef41Sopenharmony_ci            ].join('\n'),
51091cb0ef41Sopenharmony_ci            detail: '',
51101cb0ef41Sopenharmony_ci          },
51111cb0ef41Sopenharmony_ci        },
51121cb0ef41Sopenharmony_ci        'should output json containing top-level deps and their deps only'
51131cb0ef41Sopenharmony_ci      )
51141cb0ef41Sopenharmony_ci    })
51151cb0ef41Sopenharmony_ci
51161cb0ef41Sopenharmony_ci    t.test('from lockfile', async t => {
51171cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
51181cb0ef41Sopenharmony_ci        config: {
51191cb0ef41Sopenharmony_ci          ...lock,
51201cb0ef41Sopenharmony_ci          ...json,
51211cb0ef41Sopenharmony_ci        },
51221cb0ef41Sopenharmony_ci        prefixDir: {
51231cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
51241cb0ef41Sopenharmony_ci            name: 'dedupe-lockfile',
51251cb0ef41Sopenharmony_ci            version: '1.0.0',
51261cb0ef41Sopenharmony_ci            lockfileVersion: 2,
51271cb0ef41Sopenharmony_ci            requires: true,
51281cb0ef41Sopenharmony_ci            packages: {
51291cb0ef41Sopenharmony_ci              '': {
51301cb0ef41Sopenharmony_ci                name: 'dedupe-lockfile',
51311cb0ef41Sopenharmony_ci                version: '1.0.0',
51321cb0ef41Sopenharmony_ci                dependencies: {
51331cb0ef41Sopenharmony_ci                  '@isaacs/dedupe-tests-a': '1.0.1',
51341cb0ef41Sopenharmony_ci                  '@isaacs/dedupe-tests-b': '1||2',
51351cb0ef41Sopenharmony_ci                },
51361cb0ef41Sopenharmony_ci              },
51371cb0ef41Sopenharmony_ci              'node_modules/@isaacs/dedupe-tests-a': {
51381cb0ef41Sopenharmony_ci                name: '@isaacs/dedupe-tests-a',
51391cb0ef41Sopenharmony_ci                version: '1.0.1',
51401cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51411cb0ef41Sopenharmony_ci                resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-a/-/dedupe-tests-a-1.0.1.tgz',
51421cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51431cb0ef41Sopenharmony_ci                integrity: 'sha512-8AN9lNCcBt5Xeje7fMEEpp5K3rgcAzIpTtAjYb/YMUYu8SbIVF6wz0WqACDVKvpQOUcSfNHZQNLNmue0QSwXOQ==',
51441cb0ef41Sopenharmony_ci                dependencies: {
51451cb0ef41Sopenharmony_ci                  '@isaacs/dedupe-tests-b': '1',
51461cb0ef41Sopenharmony_ci                },
51471cb0ef41Sopenharmony_ci              },
51481cb0ef41Sopenharmony_ci              'node_modules/@isaacs/dedupe-tests-a/node_modules/@isaacs/dedupe-tests-b': {
51491cb0ef41Sopenharmony_ci                name: '@isaacs/dedupe-tests-b',
51501cb0ef41Sopenharmony_ci                version: '1.0.0',
51511cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51521cb0ef41Sopenharmony_ci                resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-1.0.0.tgz',
51531cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51541cb0ef41Sopenharmony_ci                integrity: 'sha512-3nmvzIb8QL8OXODzipwoV3U8h9OQD9g9RwOPuSBQqjqSg9JZR1CCFOWNsDUtOfmwY8HFUJV9EAZ124uhqVxq+w==',
51551cb0ef41Sopenharmony_ci              },
51561cb0ef41Sopenharmony_ci              'node_modules/@isaacs/dedupe-tests-b': {
51571cb0ef41Sopenharmony_ci                name: '@isaacs/dedupe-tests-b',
51581cb0ef41Sopenharmony_ci                version: '2.0.0',
51591cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51601cb0ef41Sopenharmony_ci                resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-2.0.0.tgz',
51611cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51621cb0ef41Sopenharmony_ci                integrity: 'sha512-KTYkpRv9EzlmCg4Gsm/jpclWmRYFCXow8GZKJXjK08sIZBlElTZEa5Bw/UQxIvEfcKmWXczSqItD49Kr8Ax4UA==',
51631cb0ef41Sopenharmony_ci              },
51641cb0ef41Sopenharmony_ci            },
51651cb0ef41Sopenharmony_ci            dependencies: {
51661cb0ef41Sopenharmony_ci              '@isaacs/dedupe-tests-a': {
51671cb0ef41Sopenharmony_ci                version: '1.0.1',
51681cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51691cb0ef41Sopenharmony_ci                resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-a/-/dedupe-tests-a-1.0.1.tgz',
51701cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51711cb0ef41Sopenharmony_ci                integrity: 'sha512-8AN9lNCcBt5Xeje7fMEEpp5K3rgcAzIpTtAjYb/YMUYu8SbIVF6wz0WqACDVKvpQOUcSfNHZQNLNmue0QSwXOQ==',
51721cb0ef41Sopenharmony_ci                requires: {
51731cb0ef41Sopenharmony_ci                  '@isaacs/dedupe-tests-b': '1',
51741cb0ef41Sopenharmony_ci                },
51751cb0ef41Sopenharmony_ci                dependencies: {
51761cb0ef41Sopenharmony_ci                  '@isaacs/dedupe-tests-b': {
51771cb0ef41Sopenharmony_ci                    version: '1.0.0',
51781cb0ef41Sopenharmony_ci                    /* eslint-disable-next-line max-len */
51791cb0ef41Sopenharmony_ci                    resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-1.0.0.tgz',
51801cb0ef41Sopenharmony_ci                    /* eslint-disable-next-line max-len */
51811cb0ef41Sopenharmony_ci                    integrity: 'sha512-3nmvzIb8QL8OXODzipwoV3U8h9OQD9g9RwOPuSBQqjqSg9JZR1CCFOWNsDUtOfmwY8HFUJV9EAZ124uhqVxq+w==',
51821cb0ef41Sopenharmony_ci                  },
51831cb0ef41Sopenharmony_ci                },
51841cb0ef41Sopenharmony_ci              },
51851cb0ef41Sopenharmony_ci              '@isaacs/dedupe-tests-b': {
51861cb0ef41Sopenharmony_ci                version: '2.0.0',
51871cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51881cb0ef41Sopenharmony_ci                resolved: 'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-2.0.0.tgz',
51891cb0ef41Sopenharmony_ci                /* eslint-disable-next-line max-len */
51901cb0ef41Sopenharmony_ci                integrity: 'sha512-KTYkpRv9EzlmCg4Gsm/jpclWmRYFCXow8GZKJXjK08sIZBlElTZEa5Bw/UQxIvEfcKmWXczSqItD49Kr8Ax4UA==',
51911cb0ef41Sopenharmony_ci              },
51921cb0ef41Sopenharmony_ci            },
51931cb0ef41Sopenharmony_ci          }),
51941cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
51951cb0ef41Sopenharmony_ci            name: 'dedupe-lockfile',
51961cb0ef41Sopenharmony_ci            version: '1.0.0',
51971cb0ef41Sopenharmony_ci            dependencies: {
51981cb0ef41Sopenharmony_ci              '@isaacs/dedupe-tests-a': '1.0.1',
51991cb0ef41Sopenharmony_ci              '@isaacs/dedupe-tests-b': '1||2',
52001cb0ef41Sopenharmony_ci            },
52011cb0ef41Sopenharmony_ci          }),
52021cb0ef41Sopenharmony_ci        },
52031cb0ef41Sopenharmony_ci      })
52041cb0ef41Sopenharmony_ci      await ls.exec([])
52051cb0ef41Sopenharmony_ci      t.same(
52061cb0ef41Sopenharmony_ci        jsonParse(result()),
52071cb0ef41Sopenharmony_ci        {
52081cb0ef41Sopenharmony_ci          version: '1.0.0',
52091cb0ef41Sopenharmony_ci          name: 'dedupe-lockfile',
52101cb0ef41Sopenharmony_ci          dependencies: {
52111cb0ef41Sopenharmony_ci            '@isaacs/dedupe-tests-a': {
52121cb0ef41Sopenharmony_ci              version: '1.0.1',
52131cb0ef41Sopenharmony_ci              overridden: false,
52141cb0ef41Sopenharmony_ci              resolved:
52151cb0ef41Sopenharmony_ci                'https://registry.npmjs.org/@isaacs/dedupe-tests-a/-/dedupe-tests-a-1.0.1.tgz',
52161cb0ef41Sopenharmony_ci              dependencies: {
52171cb0ef41Sopenharmony_ci                '@isaacs/dedupe-tests-b': {
52181cb0ef41Sopenharmony_ci                  version: '1.0.0',
52191cb0ef41Sopenharmony_ci                  overridden: false,
52201cb0ef41Sopenharmony_ci                  resolved:
52211cb0ef41Sopenharmony_ci                    'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-1.0.0.tgz',
52221cb0ef41Sopenharmony_ci                },
52231cb0ef41Sopenharmony_ci              },
52241cb0ef41Sopenharmony_ci            },
52251cb0ef41Sopenharmony_ci            '@isaacs/dedupe-tests-b': {
52261cb0ef41Sopenharmony_ci              version: '2.0.0',
52271cb0ef41Sopenharmony_ci              overridden: false,
52281cb0ef41Sopenharmony_ci              resolved:
52291cb0ef41Sopenharmony_ci                'https://registry.npmjs.org/@isaacs/dedupe-tests-b/-/dedupe-tests-b-2.0.0.tgz',
52301cb0ef41Sopenharmony_ci            },
52311cb0ef41Sopenharmony_ci          },
52321cb0ef41Sopenharmony_ci        },
52331cb0ef41Sopenharmony_ci        'should output json containing only prod deps'
52341cb0ef41Sopenharmony_ci      )
52351cb0ef41Sopenharmony_ci    })
52361cb0ef41Sopenharmony_ci
52371cb0ef41Sopenharmony_ci    t.test('using aliases', async t => {
52381cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
52391cb0ef41Sopenharmony_ci        config: {
52401cb0ef41Sopenharmony_ci          ...lock,
52411cb0ef41Sopenharmony_ci          ...json,
52421cb0ef41Sopenharmony_ci        },
52431cb0ef41Sopenharmony_ci        prefixDir: {
52441cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
52451cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
52461cb0ef41Sopenharmony_ci            version: '1.0.0',
52471cb0ef41Sopenharmony_ci            dependencies: {
52481cb0ef41Sopenharmony_ci              a: 'npm:b@1.0.0',
52491cb0ef41Sopenharmony_ci            },
52501cb0ef41Sopenharmony_ci          }),
52511cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
52521cb0ef41Sopenharmony_ci            dependencies: {
52531cb0ef41Sopenharmony_ci              a: {
52541cb0ef41Sopenharmony_ci                version: 'npm:b@1.0.0',
52551cb0ef41Sopenharmony_ci                resolved: 'https://localhost:8080/abbrev/-/abbrev-1.0.0.tgz',
52561cb0ef41Sopenharmony_ci              },
52571cb0ef41Sopenharmony_ci            },
52581cb0ef41Sopenharmony_ci          }),
52591cb0ef41Sopenharmony_ci        },
52601cb0ef41Sopenharmony_ci      })
52611cb0ef41Sopenharmony_ci      await ls.exec([])
52621cb0ef41Sopenharmony_ci      t.same(
52631cb0ef41Sopenharmony_ci        jsonParse(result()),
52641cb0ef41Sopenharmony_ci        {
52651cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
52661cb0ef41Sopenharmony_ci          version: '1.0.0',
52671cb0ef41Sopenharmony_ci          dependencies: {
52681cb0ef41Sopenharmony_ci            a: {
52691cb0ef41Sopenharmony_ci              version: '1.0.0',
52701cb0ef41Sopenharmony_ci              overridden: false,
52711cb0ef41Sopenharmony_ci              resolved: 'https://localhost:8080/abbrev/-/abbrev-1.0.0.tgz',
52721cb0ef41Sopenharmony_ci            },
52731cb0ef41Sopenharmony_ci          },
52741cb0ef41Sopenharmony_ci        },
52751cb0ef41Sopenharmony_ci        'should output json containing aliases'
52761cb0ef41Sopenharmony_ci      )
52771cb0ef41Sopenharmony_ci    })
52781cb0ef41Sopenharmony_ci
52791cb0ef41Sopenharmony_ci    t.test('resolved points to git ref', async t => {
52801cb0ef41Sopenharmony_ci      const { result, ls } = await mockLs(t, {
52811cb0ef41Sopenharmony_ci        config: {
52821cb0ef41Sopenharmony_ci          ...lock,
52831cb0ef41Sopenharmony_ci          ...json,
52841cb0ef41Sopenharmony_ci          long: false,
52851cb0ef41Sopenharmony_ci        },
52861cb0ef41Sopenharmony_ci        prefixDir: {
52871cb0ef41Sopenharmony_ci          'package.json': JSON.stringify({
52881cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
52891cb0ef41Sopenharmony_ci            version: '1.0.0',
52901cb0ef41Sopenharmony_ci            dependencies: {
52911cb0ef41Sopenharmony_ci              abbrev: 'git+https://github.com/isaacs/abbrev-js.git',
52921cb0ef41Sopenharmony_ci            },
52931cb0ef41Sopenharmony_ci          }),
52941cb0ef41Sopenharmony_ci          'package-lock.json': JSON.stringify({
52951cb0ef41Sopenharmony_ci            name: 'test-npm-ls',
52961cb0ef41Sopenharmony_ci            version: '1.0.0',
52971cb0ef41Sopenharmony_ci            lockfileVersion: 2,
52981cb0ef41Sopenharmony_ci            requires: true,
52991cb0ef41Sopenharmony_ci            dependencies: {
53001cb0ef41Sopenharmony_ci              abbrev: {
53011cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
53021cb0ef41Sopenharmony_ci                version: 'git+ssh://git@github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
53031cb0ef41Sopenharmony_ci                from: 'abbrev@git+https://github.com/isaacs/abbrev-js.git',
53041cb0ef41Sopenharmony_ci              },
53051cb0ef41Sopenharmony_ci            },
53061cb0ef41Sopenharmony_ci          }),
53071cb0ef41Sopenharmony_ci        },
53081cb0ef41Sopenharmony_ci      })
53091cb0ef41Sopenharmony_ci      await ls.exec([])
53101cb0ef41Sopenharmony_ci      t.same(
53111cb0ef41Sopenharmony_ci        jsonParse(result()),
53121cb0ef41Sopenharmony_ci        {
53131cb0ef41Sopenharmony_ci          name: 'test-npm-ls',
53141cb0ef41Sopenharmony_ci          version: '1.0.0',
53151cb0ef41Sopenharmony_ci          dependencies: {
53161cb0ef41Sopenharmony_ci            abbrev: {
53171cb0ef41Sopenharmony_ci              /* eslint-disable-next-line max-len */
53181cb0ef41Sopenharmony_ci              resolved: 'git+ssh://git@github.com/isaacs/abbrev-js.git#b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c',
53191cb0ef41Sopenharmony_ci              overridden: false,
53201cb0ef41Sopenharmony_ci            },
53211cb0ef41Sopenharmony_ci          },
53221cb0ef41Sopenharmony_ci        },
53231cb0ef41Sopenharmony_ci        'should output json containing git refs'
53241cb0ef41Sopenharmony_ci      )
53251cb0ef41Sopenharmony_ci    })
53261cb0ef41Sopenharmony_ci  })
53271cb0ef41Sopenharmony_ci})
5328