Skip to content

Commit

Permalink
test: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed May 24, 2023
1 parent a53ef4d commit ce61f8d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 26 deletions.
14 changes: 7 additions & 7 deletions pkg-manager/core/test/install/autoInstallPeers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
},
})
}
Expand Down Expand Up @@ -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',
},
})
}
Expand All @@ -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',
},
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg-manager/core/test/install/excludeLinksFromLockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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',
})
})
6 changes: 3 additions & 3 deletions pkg-manager/core/test/install/frozenLockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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: '*' }))

Expand Down Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions pkg-manager/core/test/install/optionalDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 () => {
Expand Down
1 change: 1 addition & 0 deletions pkg-manager/plugin-commands-installation/src/unlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function handler (
| 'engineStrict'
| 'hooks'
| 'linkWorkspacePackages'
| 'saveWorkspaceProtocol'
| 'selectedProjectsGraph'
| 'rawLocalConfig'
| 'registries'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ test('recursive linking/unlinking', async () => {
allProjectsGraph,
dir: process.cwd(),
recursive: true,
saveWorkspaceProtocol: false,
selectedProjectsGraph,
workspaceDir: process.cwd(),
})
Expand All @@ -51,6 +52,7 @@ test('recursive linking/unlinking', async () => {
allProjectsGraph,
dir: process.cwd(),
recursive: true,
saveWorkspaceProtocol: false,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, [])
Expand Down Expand Up @@ -96,6 +98,7 @@ test('recursive unlink specific package', async () => {
allProjectsGraph,
dir: process.cwd(),
recursive: true,
saveWorkspaceProtocol: false,
selectedProjectsGraph,
workspaceDir: process.cwd(),
})
Expand All @@ -114,6 +117,7 @@ test('recursive unlink specific package', async () => {
allProjectsGraph,
dir: process.cwd(),
recursive: true,
saveWorkspaceProtocol: false,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['is-positive'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
{
Expand Down Expand Up @@ -221,7 +221,7 @@ test('interactive update of dev dependencies only', async () => {
expect(
Object.keys(lockfile.packages ?? {})
).toStrictEqual(
['/[email protected].0', '/[email protected]']
['/[email protected].1', '/[email protected]']
)
})

Expand Down
24 changes: 14 additions & 10 deletions pnpm/test/monorepo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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',
},
Expand All @@ -351,16 +355,16 @@ 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',
},
},
{
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',
},
Expand All @@ -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',
},
Expand Down Expand Up @@ -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:*',
},
},
},
Expand Down Expand Up @@ -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',
},
},
Expand Down Expand Up @@ -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<Lockfile>(WANTED_LOCKFILE)

Expand Down

0 comments on commit ce61f8d

Please sign in to comment.