Debian Codegraph @

smoke-tests/test/workspace-ua.js

raw
1
2 const t = require('tap')
3 const setup = require('./fixtures/setup.js')
4
5 t.test('basic', async t => {
6 const { registry, npm } = await setup(t)
7
8 const mock = () => registry.nock
9 .get(`/fail_reflect_user_agent`)
10 .reply(404, {}, { 'npm-notice': (req) => req.headers['user-agent'] })
11
12 await t.test('npm install sends correct user-agent', async t => {
13 await npm('init', '-y')
14 await npm('init', '-y', `--workspace=foo`)
15
16 mock()
17 await t.rejects(
18 npm('install', 'fail_reflect_user_agent'),
19 {
20 stderr: /workspaces\/false/,
21 },
22 'workspaces/false is present in output'
23 )
24
25 mock()
26 await t.rejects(
27 npm('install', 'fail_reflect_user_agent', '--workspaces'),
28 {
29 stderr: /workspaces\/true/,
30 },
31 'workspaces/true is present in output'
32 )
33 })
34 })