Debian Codegraph @

smoke-tests/test/large-install.js

raw
1 const t = require('tap')
2 const path = require('node:path')
3 const setup = require('./fixtures/setup.js')
4
5 const getFixture = (p) => require(
6 path.resolve(__dirname, './fixtures/large-install', p))
7
8 const runTest = async (t, { lowMemory } = {}) => {
9 const { npm } = await setup(t, {
10 // This test relies on the actual production registry
11 mockRegistry: false,
12 testdir: {
13 project: {
14 'package.json': getFixture('package.json'),
15 ...lowMemory ? {} : { 'package-lock.json': getFixture('package-lock.json') },
16 },
17 },
18 })
19 return npm('install', '--no-audit', '--no-fund', {
20 env: lowMemory ? { NODE_OPTIONS: '--max-old-space-size=500' } : {},
21 })
22 }
23
24 // This test was originally created for https://github.com/npm/cli/issues/6763
25 // but was later removed after the corresponding Node bug was fixed and the test
26 // started flaking. These flakes were most likely a sign that there was actually
27 // a bug where maxSockets were not being respected https://github.com/npm/cli/issues/7072.
28 // So now this test has been brought back and if it does start flaking again it
29 // should be investigated.
30 t.test('large install', async t => {
31 const { stdout } = await runTest(t)
32 t.match(stdout, /added \d+ packages/)
33 })
34
35 t.test('large install, no lock and low memory', async t => {
36 // Run the same install but with no lockfile and constrained max-old-space-size
37 const { stdout } = await runTest(t, { lowMemory: true })
38 t.match(stdout, /added \d+ packages/)
39 })