Skip to content

Commit

Permalink
test: making a test more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Mar 22, 2020
1 parent 5e6e9a8 commit 9890f37
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/pnpm/test/monorepo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,46 +296,42 @@ test('do not get confused by filtered dependencies when searching for dependents
version: '1.0.0',

dependencies: { 'unused-project-1': '1.0.0', 'unused-project-2': '1.0.0' },
devDependencies: { 'json-append': '1' },
scripts: {
test: `node -e "process.stdout.write('project-2')" | json-append ../output.json`,
test: `node -e "process.stdout.write('printed' + ' by project-2')"`,
},
},
{
name: 'project-3',
version: '1.0.0',

dependencies: { 'project-2': '1.0.0' },
devDependencies: { 'json-append': '1' },
scripts: {
test: `node -e "process.stdout.write('project-3')" | json-append ../output.json`,
test: `node -e "process.stdout.write('printed' + ' by project-3')"`,
},
},
{
name: 'project-4',
version: '1.0.0',

dependencies: { 'project-2': '1.0.0', 'unused-project-1': '1.0.0', 'unused-project-2': '1.0.0' },
devDependencies: { 'json-append': '1' },
scripts: {
test: `node -e "process.stdout.write('project-4')" | json-append ../output.json`,
test: `node -e "process.stdout.write('printed' + ' by project-4')"`,
},
},
])
await fs.writeFile('.npmrc', 'link-workspace-packages = true', 'utf8')
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] })

await execPnpm(['recursive', 'install'])

process.chdir('project-2')

await execPnpm(['--filter=...project-2', 'run', 'test'])
const { stdout } = execPnpmSync(['--filter=...project-2', 'run', 'test'])

const outputs = await import(path.resolve('..', 'output.json')) as string[]
// project-2 should be executed first, we cannot say anything about the order
// of the last two packages.
t.equal(outputs[0], 'project-2')
t.equal(outputs.length, 3)
const output = stdout.toString()
const project2Output = output.indexOf('printed by project-2')
const project3Output = output.indexOf('printed by project-3')
const project4Output = output.indexOf('printed by project-4')
t.ok(project2Output < project3Output)
t.ok(project2Output < project4Output)
})

test('installation with --link-workspace-packages links packages even if they were previously installed from registry', async (t: tape.Test) => {
Expand Down

0 comments on commit 9890f37

Please sign in to comment.