-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
nx-bail.test.ts
54 lines (49 loc) · 1.54 KB
/
nx-bail.test.ts
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
import { newProject, runCLI, uniq, updateProjectConfig } from '@nrwl/e2e/utils';
describe('Nx Bail', () => {
beforeEach(() => newProject());
it('should stop executing all tasks when one of the tasks fails', async () => {
const myapp1 = uniq('a');
const myapp2 = uniq('b');
runCLI(`generate @nrwl/web:app ${myapp1}`);
runCLI(`generate @nrwl/web:app ${myapp2}`);
updateProjectConfig(myapp1, (c) => {
c.targets['error'] = {
executor: 'nx:run-commands',
options: {
command: 'echo boom1 && exit 1',
},
};
return c;
});
updateProjectConfig(myapp2, (c) => {
c.targets['error'] = {
executor: 'nx:run-commands',
options: {
command: 'echo boom2 && exit 1',
},
};
return c;
});
let withoutBail = runCLI(`run-many --target=error --all --parallel=1`, {
silenceError: true,
})
.split('\n')
.map((r) => r.trim())
.filter((r) => r);
withoutBail = withoutBail.slice(withoutBail.indexOf('Failed tasks:'));
expect(withoutBail).toContain(`- ${myapp1}:error`);
expect(withoutBail).toContain(`- ${myapp2}:error`);
let withBail = runCLI(
`run-many --target=error --all --parallel=1 --nx-bail`,
{
silenceError: true,
}
)
.split('\n')
.map((r) => r.trim())
.filter((r) => r);
withBail = withBail.slice(withBail.indexOf('Failed tasks:'));
expect(withBail).toContain(`- ${myapp1}:error`);
expect(withBail).not.toContain(`- ${myapp2}:error`);
});
});