-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration test for --fail-fast and --serial 🛡️
- Loading branch information
1 parent
5b18779
commit d07b5c2
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,65 @@ test('fetch just a single package', async t => { | |
test('fetch just a list of package', async t => { | ||
const stream = fakeStream(); | ||
// had to pin version for test stability | ||
await main({argv: {_: ['[email protected]', '[email protected]']}, stream}); | ||
await main({argv: {_: ['[email protected]', '[email protected]'], serial: 1}, stream}); | ||
const EXPECT_TEXT = `- Fetching stats for package [email protected] | ||
ℹ lodash (2.4.2) has 0 dependencies for a weight of 27.94KB (10.04KB gzipped) | ||
- Fetching stats for package [email protected] | ||
ℹ moment (1.2.0) has 0 dependencies for a weight of 114.1KB (14.83KB gzipped) | ||
ℹ total (2 packages) has 0 dependencies for a weight of 142.04KB (24.87KB gzipped) | ||
`; | ||
|
||
t.deepEqual(stream.getContent().split('\n').sort(), EXPECT_TEXT.split('\n').sort()); | ||
}); | ||
|
||
test('fetch all not stoping on error', async t => { | ||
const stream = fakeStream(); | ||
// had to pin version for test stability | ||
await t.throwsAsync( | ||
() => | ||
main({ | ||
argv: {_: ['[email protected]', '@oh-no/no-noooo', '[email protected]'], serial: 1}, | ||
stream | ||
}), | ||
{message: /The package you were looking for doesn't exist./} | ||
// TODO: enforce exact wording (and adequate formating) | ||
); | ||
t.is( | ||
stream.getContent(), | ||
`- Fetching stats for package [email protected] | ||
ℹ lodash (2.4.2) has 0 dependencies for a weight of 27.94KB (10.04KB gzipped) | ||
- Fetching stats for package @oh-no/no-noooo | ||
✖ resolving @oh-no/no-noooo failed: The package you were looking for doesn't exist. | ||
- Fetching stats for package [email protected] | ||
ℹ moment (1.2.0) has 0 dependencies for a weight of 114.1KB (14.83KB gzipped) | ||
` | ||
); | ||
}); | ||
|
||
test('fetch all stoping on first error with flag', async t => { | ||
const stream = fakeStream(); | ||
// had to pin version for test stability | ||
const err = await main({ | ||
argv: {_: ['[email protected]', '@oh-no/no-noooo', '[email protected]'], serial: 1, 'fail-fast': true}, | ||
stream | ||
}).catch(err => err); | ||
|
||
t.is( | ||
stream.getContent(), | ||
`- Fetching stats for package [email protected] | ||
ℹ lodash (2.4.2) has 0 dependencies for a weight of 27.94KB (10.04KB gzipped) | ||
- Fetching stats for package @oh-no/no-noooo | ||
✖ resolving @oh-no/no-noooo failed: The package you were looking for doesn't exist. | ||
` | ||
); | ||
t.is(err.message, "The package you were looking for doesn't exist."); | ||
}); | ||
|
||
test('fetch just a list of package serialy', async t => { | ||
const stream = fakeStream(); | ||
// had to pin version for test stability | ||
await main({argv: {_: ['[email protected]', '[email protected]'], serial: 1}, stream}); | ||
|
||
t.is( | ||
stream.getContent(), | ||
|