Skip to content

Commit ce61f8d

Browse files
committed
test: improvements
1 parent a53ef4d commit ce61f8d

File tree

8 files changed

+35
-26
lines changed

8 files changed

+35
-26
lines changed

pkg-manager/core/test/install/autoInstallPeers.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ test('automatically install root peer dependencies', async () => {
170170

171171
let manifest = await install({
172172
dependencies: {
173-
'is-negative': '^1.0.0',
173+
'is-negative': '^1.0.1',
174174
},
175175
peerDependencies: {
176176
'is-positive': '^1.0.0',
@@ -188,8 +188,8 @@ test('automatically install root peer dependencies', async () => {
188188
version: '1.0.0',
189189
},
190190
'is-negative': {
191-
specifier: '^1.0.0',
192-
version: '1.0.0',
191+
specifier: '^1.0.1',
192+
version: '1.0.1',
193193
},
194194
})
195195
}
@@ -220,8 +220,8 @@ test('automatically install root peer dependencies', async () => {
220220
version: '1.0.0',
221221
},
222222
'is-negative': {
223-
specifier: '^1.0.0',
224-
version: '1.0.0',
223+
specifier: '^1.0.1',
224+
version: '1.0.1',
225225
},
226226
})
227227
}
@@ -245,8 +245,8 @@ test('automatically install root peer dependencies', async () => {
245245
version: '1.0.0',
246246
},
247247
'is-negative': {
248-
specifier: '^1.0.0',
249-
version: '1.0.0',
248+
specifier: '^1.0.1',
249+
version: '1.0.1',
250250
},
251251
})
252252
}

pkg-manager/core/test/install/excludeLinksFromLockfile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ test('links resolved from workspace protocol dependencies are not removed', asyn
245245

246246
dependencies: {
247247
'is-positive': '1.0.0',
248-
'project-2': 'workspace:1.0.0',
248+
'project-2': 'workspace:*',
249249
},
250250
}
251251
const pkg2 = {
@@ -303,7 +303,7 @@ test('links resolved from workspace protocol dependencies are not removed', asyn
303303

304304
const lockfile: LockfileV6 = await readYamlFile(WANTED_LOCKFILE)
305305
expect(lockfile.importers['project-1'].dependencies?.['project-2']).toStrictEqual({
306-
specifier: 'workspace:1.0.0',
306+
specifier: 'workspace:*',
307307
version: 'link:../project-2',
308308
})
309309
})

pkg-manager/core/test/install/frozenLockfile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test(`frozen-lockfile: installation fails if specs in package.json don't match t
1515
await install(
1616
{
1717
dependencies: {
18-
'is-positive': '^3.0.0',
18+
'is-positive': '1.0.0',
1919
},
2020
},
2121
await testDefaults()
@@ -35,7 +35,7 @@ test(`frozen-lockfile+hoistPattern: installation fails if specs in package.json
3535

3636
await install({
3737
dependencies: {
38-
'is-positive': '^3.0.0',
38+
'is-positive': '1.0.0',
3939
},
4040
}, await testDefaults({ hoistPattern: '*' }))
4141

@@ -67,7 +67,7 @@ test(`frozen-lockfile: fail on a shared ${WANTED_LOCKFILE} that does not satisfy
6767
name: 'p1',
6868

6969
dependencies: {
70-
'is-positive': '^3.0.0',
70+
'is-positive': '1.0.0',
7171
},
7272
},
7373
rootDir: path.resolve('p1'),

pkg-manager/core/test/install/optionalDependencies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test('skip non-existing optional dependency', async () => {
3636
const reporter = sinon.spy()
3737
await install({
3838
dependencies: {
39-
'is-positive': '*',
39+
'is-positive': '1.0.0',
4040
},
4141
optionalDependencies: {
4242
'@pnpm.e2e/i-do-not-exist': '1000',
@@ -56,7 +56,7 @@ test('skip non-existing optional dependency', async () => {
5656

5757
const lockfile = await project.readLockfile()
5858

59-
expect(lockfile.dependencies['is-positive'].specifier).toBe('*')
59+
expect(lockfile.dependencies['is-positive'].specifier).toBe('1.0.0')
6060
})
6161

6262
test('skip optional dependency that does not support the current OS', async () => {

pkg-manager/plugin-commands-installation/src/unlink.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export async function handler (
5050
| 'engineStrict'
5151
| 'hooks'
5252
| 'linkWorkspacePackages'
53+
| 'saveWorkspaceProtocol'
5354
| 'selectedProjectsGraph'
5455
| 'rawLocalConfig'
5556
| 'registries'

pkg-manager/plugin-commands-installation/test/linkRecursive.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ test('recursive linking/unlinking', async () => {
3333
allProjectsGraph,
3434
dir: process.cwd(),
3535
recursive: true,
36+
saveWorkspaceProtocol: false,
3637
selectedProjectsGraph,
3738
workspaceDir: process.cwd(),
3839
})
@@ -51,6 +52,7 @@ test('recursive linking/unlinking', async () => {
5152
allProjectsGraph,
5253
dir: process.cwd(),
5354
recursive: true,
55+
saveWorkspaceProtocol: false,
5456
selectedProjectsGraph,
5557
workspaceDir: process.cwd(),
5658
}, [])
@@ -96,6 +98,7 @@ test('recursive unlink specific package', async () => {
9698
allProjectsGraph,
9799
dir: process.cwd(),
98100
recursive: true,
101+
saveWorkspaceProtocol: false,
99102
selectedProjectsGraph,
100103
workspaceDir: process.cwd(),
101104
})
@@ -114,6 +117,7 @@ test('recursive unlink specific package', async () => {
114117
allProjectsGraph,
115118
dir: process.cwd(),
116119
recursive: true,
120+
saveWorkspaceProtocol: false,
117121
selectedProjectsGraph,
118122
workspaceDir: process.cwd(),
119123
}, ['is-positive'])

pkg-manager/plugin-commands-installation/test/update/interactive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ test('interactive update of dev dependencies only', async () => {
166166
name: 'project1',
167167

168168
dependencies: {
169-
'is-negative': '^1.0.0',
169+
'is-negative': '^1.0.1',
170170
},
171171
},
172172
{
@@ -221,7 +221,7 @@ test('interactive update of dev dependencies only', async () => {
221221
expect(
222222
Object.keys(lockfile.packages ?? {})
223223
).toStrictEqual(
224-
224+
225225
)
226226
})
227227

pnpm/test/monorepo/index.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ test('linking a package inside a monorepo with --link-workspace-packages', async
241241
},
242242
])
243243

244-
await fs.writeFile('.npmrc', 'link-workspace-packages = true\nshared-workspace-lockfile=false', 'utf8')
244+
await fs.writeFile('.npmrc', `
245+
link-workspace-packages = true
246+
shared-workspace-lockfile=false
247+
save-workspace-protocol=false
248+
`, 'utf8')
245249
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] })
246250

247251
process.chdir('project-1')
@@ -341,8 +345,8 @@ test('test-pattern is respected by the test script', async () => {
341345
{
342346
name: 'project-1',
343347
version: '1.0.0',
344-
dependencies: { 'project-2': '1.0.0', 'project-3': '1.0.0' },
345-
devDependencies: { 'json-append': '1' },
348+
dependencies: { 'project-2': 'workspace:*', 'project-3': 'workspace:*' },
349+
devDependencies: { 'json-append': '1.1.1' },
346350
scripts: {
347351
test: 'node -e "process.stdout.write(\'project-1\')" | json-append ../output.json',
348352
},
@@ -351,16 +355,16 @@ test('test-pattern is respected by the test script', async () => {
351355
name: 'project-2',
352356
version: '1.0.0',
353357
dependencies: {},
354-
devDependencies: { 'json-append': '1' },
358+
devDependencies: { 'json-append': '1.1.1' },
355359
scripts: {
356360
test: 'node -e "process.stdout.write(\'project-2\')" | json-append ../output.json',
357361
},
358362
},
359363
{
360364
name: 'project-3',
361365
version: '1.0.0',
362-
dependencies: { 'project-2': '1.0.0' },
363-
devDependencies: { 'json-append': '1' },
366+
dependencies: { 'project-2': 'workspace:*' },
367+
devDependencies: { 'json-append': '1.1.1' },
364368
scripts: {
365369
test: 'node -e "process.stdout.write(\'project-3\')" | json-append ../output.json',
366370
},
@@ -369,7 +373,7 @@ test('test-pattern is respected by the test script', async () => {
369373
name: 'project-4',
370374
version: '1.0.0',
371375
dependencies: {},
372-
devDependencies: { 'json-append': '1' },
376+
devDependencies: { 'json-append': '1.1.1' },
373377
scripts: {
374378
test: 'node -e "process.stdout.write(\'project-4\')" | json-append ../output.json',
375379
},
@@ -935,7 +939,7 @@ test("shared-workspace-lockfile: don't install dependencies in projects that are
935939

936940
dependencies: {
937941
'is-positive': '1.0.0',
938-
'package-2': '1.0.0',
942+
'package-2': 'workspace:*',
939943
},
940944
},
941945
},
@@ -976,7 +980,7 @@ test("shared-workspace-lockfile: don't install dependencies in projects that are
976980
version: '1.0.0',
977981
},
978982
'package-2': {
979-
specifier: '1.0.0',
983+
specifier: 'workspace:*',
980984
version: 'link:../package-2',
981985
},
982986
},
@@ -1040,7 +1044,7 @@ test('shared-workspace-lockfile: install dependencies in projects that are relat
10401044

10411045
process.chdir('monorepo/workspace')
10421046

1043-
await execPnpm(['recursive', 'install', '--store-dir', 'store', '--shared-workspace-lockfile', '--link-workspace-packages'])
1047+
await execPnpm(['-r', 'install', '--store-dir', 'store', '--shared-workspace-lockfile', '--link-workspace-packages', '--no-save-workspace-protocol'])
10441048

10451049
const lockfile = await readYamlFile<Lockfile>(WANTED_LOCKFILE)
10461050

0 commit comments

Comments
 (0)