-
-
Notifications
You must be signed in to change notification settings - Fork 128
/
enabled.js
60 lines (53 loc) · 1.03 KB
/
enabled.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {serial as test} from 'ava';
import Listr from '..';
import SimpleRenderer from './fixtures/simple-renderer';
import {testOutput} from './fixtures/utils';
test('do not run disabled tasks', async t => {
const list = new Listr([
{
title: 'foo',
task: () => Promise.resolve()
},
{
title: 'bar',
enabled: ctx => ctx.run === true,
task: () => Promise.resolve()
}
], {
renderer: SimpleRenderer
});
testOutput(t, [
'foo [started]',
'foo [completed]',
'done'
]);
await list.run();
});
test('run enabled task', async t => {
const list = new Listr([
{
title: 'foo',
task: (ctx, task) => Promise.reject(new Error('Something went wrong'))
.catch(() => {
task.skip('It failed');
ctx.failed = true;
})
},
{
title: 'bar',
enabled: ctx => ctx.failed === true,
task: () => Promise.resolve()
}
], {
renderer: SimpleRenderer
});
testOutput(t, [
'foo [started]',
'foo [skipped]',
'> It failed',
'bar [started]',
'bar [completed]',
'done'
]);
await list.run();
});