From ce61f8d3c29eee46cee38d56ced45aea8a439a53 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 24 May 2023 16:56:58 +0300 Subject: [PATCH] test: improvements --- .../core/test/install/autoInstallPeers.ts | 14 +++++------ .../test/install/excludeLinksFromLockfile.ts | 4 ++-- .../core/test/install/frozenLockfile.ts | 6 ++--- .../core/test/install/optionalDependencies.ts | 4 ++-- .../src/unlink.ts | 1 + .../test/linkRecursive.ts | 4 ++++ .../test/update/interactive.ts | 4 ++-- pnpm/test/monorepo/index.ts | 24 +++++++++++-------- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/pkg-manager/core/test/install/autoInstallPeers.ts b/pkg-manager/core/test/install/autoInstallPeers.ts index 7e6881973ee..252224da31d 100644 --- a/pkg-manager/core/test/install/autoInstallPeers.ts +++ b/pkg-manager/core/test/install/autoInstallPeers.ts @@ -170,7 +170,7 @@ test('automatically install root peer dependencies', async () => { let manifest = await install({ dependencies: { - 'is-negative': '^1.0.0', + 'is-negative': '^1.0.1', }, peerDependencies: { 'is-positive': '^1.0.0', @@ -188,8 +188,8 @@ test('automatically install root peer dependencies', async () => { version: '1.0.0', }, 'is-negative': { - specifier: '^1.0.0', - version: '1.0.0', + specifier: '^1.0.1', + version: '1.0.1', }, }) } @@ -220,8 +220,8 @@ test('automatically install root peer dependencies', async () => { version: '1.0.0', }, 'is-negative': { - specifier: '^1.0.0', - version: '1.0.0', + specifier: '^1.0.1', + version: '1.0.1', }, }) } @@ -245,8 +245,8 @@ test('automatically install root peer dependencies', async () => { version: '1.0.0', }, 'is-negative': { - specifier: '^1.0.0', - version: '1.0.0', + specifier: '^1.0.1', + version: '1.0.1', }, }) } diff --git a/pkg-manager/core/test/install/excludeLinksFromLockfile.ts b/pkg-manager/core/test/install/excludeLinksFromLockfile.ts index 44adb98b21e..b3392e0c5af 100644 --- a/pkg-manager/core/test/install/excludeLinksFromLockfile.ts +++ b/pkg-manager/core/test/install/excludeLinksFromLockfile.ts @@ -245,7 +245,7 @@ test('links resolved from workspace protocol dependencies are not removed', asyn dependencies: { 'is-positive': '1.0.0', - 'project-2': 'workspace:1.0.0', + 'project-2': 'workspace:*', }, } const pkg2 = { @@ -303,7 +303,7 @@ test('links resolved from workspace protocol dependencies are not removed', asyn const lockfile: LockfileV6 = await readYamlFile(WANTED_LOCKFILE) expect(lockfile.importers['project-1'].dependencies?.['project-2']).toStrictEqual({ - specifier: 'workspace:1.0.0', + specifier: 'workspace:*', version: 'link:../project-2', }) }) diff --git a/pkg-manager/core/test/install/frozenLockfile.ts b/pkg-manager/core/test/install/frozenLockfile.ts index 929967e4afc..12cdadd8692 100644 --- a/pkg-manager/core/test/install/frozenLockfile.ts +++ b/pkg-manager/core/test/install/frozenLockfile.ts @@ -15,7 +15,7 @@ test(`frozen-lockfile: installation fails if specs in package.json don't match t await install( { dependencies: { - 'is-positive': '^3.0.0', + 'is-positive': '1.0.0', }, }, await testDefaults() @@ -35,7 +35,7 @@ test(`frozen-lockfile+hoistPattern: installation fails if specs in package.json await install({ dependencies: { - 'is-positive': '^3.0.0', + 'is-positive': '1.0.0', }, }, await testDefaults({ hoistPattern: '*' })) @@ -67,7 +67,7 @@ test(`frozen-lockfile: fail on a shared ${WANTED_LOCKFILE} that does not satisfy name: 'p1', dependencies: { - 'is-positive': '^3.0.0', + 'is-positive': '1.0.0', }, }, rootDir: path.resolve('p1'), diff --git a/pkg-manager/core/test/install/optionalDependencies.ts b/pkg-manager/core/test/install/optionalDependencies.ts index 7263eb0c11a..0b98b64788b 100644 --- a/pkg-manager/core/test/install/optionalDependencies.ts +++ b/pkg-manager/core/test/install/optionalDependencies.ts @@ -36,7 +36,7 @@ test('skip non-existing optional dependency', async () => { const reporter = sinon.spy() await install({ dependencies: { - 'is-positive': '*', + 'is-positive': '1.0.0', }, optionalDependencies: { '@pnpm.e2e/i-do-not-exist': '1000', @@ -56,7 +56,7 @@ test('skip non-existing optional dependency', async () => { const lockfile = await project.readLockfile() - expect(lockfile.dependencies['is-positive'].specifier).toBe('*') + expect(lockfile.dependencies['is-positive'].specifier).toBe('1.0.0') }) test('skip optional dependency that does not support the current OS', async () => { diff --git a/pkg-manager/plugin-commands-installation/src/unlink.ts b/pkg-manager/plugin-commands-installation/src/unlink.ts index 6cc057a2d34..dfb1b3df1fe 100644 --- a/pkg-manager/plugin-commands-installation/src/unlink.ts +++ b/pkg-manager/plugin-commands-installation/src/unlink.ts @@ -50,6 +50,7 @@ export async function handler ( | 'engineStrict' | 'hooks' | 'linkWorkspacePackages' + | 'saveWorkspaceProtocol' | 'selectedProjectsGraph' | 'rawLocalConfig' | 'registries' diff --git a/pkg-manager/plugin-commands-installation/test/linkRecursive.ts b/pkg-manager/plugin-commands-installation/test/linkRecursive.ts index 0a440fd88b9..5f2c8631edc 100644 --- a/pkg-manager/plugin-commands-installation/test/linkRecursive.ts +++ b/pkg-manager/plugin-commands-installation/test/linkRecursive.ts @@ -33,6 +33,7 @@ test('recursive linking/unlinking', async () => { allProjectsGraph, dir: process.cwd(), recursive: true, + saveWorkspaceProtocol: false, selectedProjectsGraph, workspaceDir: process.cwd(), }) @@ -51,6 +52,7 @@ test('recursive linking/unlinking', async () => { allProjectsGraph, dir: process.cwd(), recursive: true, + saveWorkspaceProtocol: false, selectedProjectsGraph, workspaceDir: process.cwd(), }, []) @@ -96,6 +98,7 @@ test('recursive unlink specific package', async () => { allProjectsGraph, dir: process.cwd(), recursive: true, + saveWorkspaceProtocol: false, selectedProjectsGraph, workspaceDir: process.cwd(), }) @@ -114,6 +117,7 @@ test('recursive unlink specific package', async () => { allProjectsGraph, dir: process.cwd(), recursive: true, + saveWorkspaceProtocol: false, selectedProjectsGraph, workspaceDir: process.cwd(), }, ['is-positive']) diff --git a/pkg-manager/plugin-commands-installation/test/update/interactive.ts b/pkg-manager/plugin-commands-installation/test/update/interactive.ts index b060b338ab4..cf79230dc39 100644 --- a/pkg-manager/plugin-commands-installation/test/update/interactive.ts +++ b/pkg-manager/plugin-commands-installation/test/update/interactive.ts @@ -166,7 +166,7 @@ test('interactive update of dev dependencies only', async () => { name: 'project1', dependencies: { - 'is-negative': '^1.0.0', + 'is-negative': '^1.0.1', }, }, { @@ -221,7 +221,7 @@ test('interactive update of dev dependencies only', async () => { expect( Object.keys(lockfile.packages ?? {}) ).toStrictEqual( - ['/is-negative@1.0.0', '/is-negative@2.1.0'] + ['/is-negative@1.0.1', '/is-negative@2.1.0'] ) }) diff --git a/pnpm/test/monorepo/index.ts b/pnpm/test/monorepo/index.ts index 047b611a914..263007cbe62 100644 --- a/pnpm/test/monorepo/index.ts +++ b/pnpm/test/monorepo/index.ts @@ -241,7 +241,11 @@ test('linking a package inside a monorepo with --link-workspace-packages', async }, ]) - await fs.writeFile('.npmrc', 'link-workspace-packages = true\nshared-workspace-lockfile=false', 'utf8') + await fs.writeFile('.npmrc', ` +link-workspace-packages = true +shared-workspace-lockfile=false +save-workspace-protocol=false +`, 'utf8') await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] }) process.chdir('project-1') @@ -341,8 +345,8 @@ test('test-pattern is respected by the test script', async () => { { name: 'project-1', version: '1.0.0', - dependencies: { 'project-2': '1.0.0', 'project-3': '1.0.0' }, - devDependencies: { 'json-append': '1' }, + dependencies: { 'project-2': 'workspace:*', 'project-3': 'workspace:*' }, + devDependencies: { 'json-append': '1.1.1' }, scripts: { test: 'node -e "process.stdout.write(\'project-1\')" | json-append ../output.json', }, @@ -351,7 +355,7 @@ test('test-pattern is respected by the test script', async () => { name: 'project-2', version: '1.0.0', dependencies: {}, - devDependencies: { 'json-append': '1' }, + devDependencies: { 'json-append': '1.1.1' }, scripts: { test: 'node -e "process.stdout.write(\'project-2\')" | json-append ../output.json', }, @@ -359,8 +363,8 @@ test('test-pattern is respected by the test script', async () => { { name: 'project-3', version: '1.0.0', - dependencies: { 'project-2': '1.0.0' }, - devDependencies: { 'json-append': '1' }, + dependencies: { 'project-2': 'workspace:*' }, + devDependencies: { 'json-append': '1.1.1' }, scripts: { test: 'node -e "process.stdout.write(\'project-3\')" | json-append ../output.json', }, @@ -369,7 +373,7 @@ test('test-pattern is respected by the test script', async () => { name: 'project-4', version: '1.0.0', dependencies: {}, - devDependencies: { 'json-append': '1' }, + devDependencies: { 'json-append': '1.1.1' }, scripts: { test: 'node -e "process.stdout.write(\'project-4\')" | json-append ../output.json', }, @@ -935,7 +939,7 @@ test("shared-workspace-lockfile: don't install dependencies in projects that are dependencies: { 'is-positive': '1.0.0', - 'package-2': '1.0.0', + 'package-2': 'workspace:*', }, }, }, @@ -976,7 +980,7 @@ test("shared-workspace-lockfile: don't install dependencies in projects that are version: '1.0.0', }, 'package-2': { - specifier: '1.0.0', + specifier: 'workspace:*', version: 'link:../package-2', }, }, @@ -1040,7 +1044,7 @@ test('shared-workspace-lockfile: install dependencies in projects that are relat process.chdir('monorepo/workspace') - await execPnpm(['recursive', 'install', '--store-dir', 'store', '--shared-workspace-lockfile', '--link-workspace-packages']) + await execPnpm(['-r', 'install', '--store-dir', 'store', '--shared-workspace-lockfile', '--link-workspace-packages', '--no-save-workspace-protocol']) const lockfile = await readYamlFile(WANTED_LOCKFILE)