Skip to content

Commit f70557a

Browse files
alan-agius4dgp1130
authored andcommitted
test: use tree-kill callback
tree-kill kills process asynchronously, but previously we didn't wait for the processes to be terminated before we continue running other tests. With this change we use the tree-kill callback method to wait for the processes to be killed before we continue with out tests.
1 parent ae02b21 commit f70557a

17 files changed

Lines changed: 84 additions & 188 deletions

tests/legacy-cli/e2e/tests/basic/e2e.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ export default function () {
6666
ng('e2e', 'test-project', '--no-webdriver-update', '--dev-server-target='),
6767
),
6868
)
69-
.then(
70-
() => killAllProcesses(),
71-
(err) => {
72-
killAllProcesses();
73-
throw err;
74-
},
75-
)
69+
.finally(() => killAllProcesses())
7670
);
7771
}

tests/legacy-cli/e2e/tests/basic/rebuild.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ export default function () {
181181
throw new Error('Expected component CSS to update.');
182182
}
183183
})
184-
.then(
185-
() => killAllProcesses(),
186-
(err: unknown) => {
187-
killAllProcesses();
188-
throw err;
189-
},
190-
)
184+
.finally(() => killAllProcesses())
191185
);
192186
}

tests/legacy-cli/e2e/tests/basic/serve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export default async function () {
77
// Serve works without HMR
88
await ngServe('--no-hmr');
99
await verifyResponse();
10-
killAllProcesses();
10+
await killAllProcesses();
1111

1212
// Serve works with HMR
1313
await ngServe('--hmr');
1414
await verifyResponse();
1515
} finally {
16-
killAllProcesses();
16+
await killAllProcesses();
1717
}
1818
}
1919

tests/legacy-cli/e2e/tests/build/poll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ export default async function () {
2424
// But a rebuild should happen roughly within the 10 second window.
2525
await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000);
2626
} finally {
27-
killAllProcesses();
27+
await killAllProcesses();
2828
}
2929
}

tests/legacy-cli/e2e/tests/build/rebuild-deps-type-check.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ export default function () {
114114
throw new Error('Expected no error but an error was shown.');
115115
}
116116
})
117-
.then(
118-
() => killAllProcesses(),
119-
(err: any) => {
120-
killAllProcesses();
121-
throw err;
122-
},
123-
)
117+
.finally(() => killAllProcesses())
124118
);
125119
}

tests/legacy-cli/e2e/tests/build/rebuild-replacements.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export default async function () {
1313
return;
1414
}
1515

16-
let error;
1716
try {
1817
await execAndWaitForOutputToMatch(
1918
'ng',
@@ -26,12 +25,7 @@ export default async function () {
2625
// Should trigger a rebuild.
2726
await appendToFile('src/environments/environment.prod.ts', `console.log('PROD');`);
2827
await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 45000);
29-
} catch (e) {
30-
error = e;
31-
}
32-
33-
killAllProcesses();
34-
if (error) {
35-
throw error;
28+
} finally {
29+
await killAllProcesses();
3630
}
3731
}

tests/legacy-cli/e2e/tests/build/rebuild-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ export default async function () {
2626
writeFile('src/app/type.ts', `export type MyType = string;`),
2727
]);
2828
} finally {
29-
killAllProcesses();
29+
await killAllProcesses();
3030
}
3131
}

tests/legacy-cli/e2e/tests/commands/serve/reload-shims.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export default async function () {
2020
/Module not found: Error: Can't resolve 'path'/,
2121
);
2222
} finally {
23-
killAllProcesses();
23+
await killAllProcesses();
2424
}
2525
}

tests/legacy-cli/e2e/tests/commands/serve/serve-path.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,5 @@ export default function () {
1818
assert.strictEqual(response.status, 200);
1919
assert.match(await response.text(), /<app-root><\/app-root>/);
2020
})
21-
.then(
22-
() => killAllProcesses(),
23-
(err) => {
24-
killAllProcesses();
25-
throw err;
26-
},
27-
);
28-
// .then(() => ngServe('--base-href', 'test/'))
29-
// .then((response) => response.text())
30-
// .then(() => fetch('http://localhost:4200/test', { headers: { 'Accept': 'text/html' } }))
31-
// .then(body => {
32-
// if (!body.match(/<app-root><\/app-root>/)) {
33-
// throw new Error('Response does not match expected value.');
34-
// }
35-
// })
36-
// .then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; });
21+
.finally(() => killAllProcesses());
3722
}

tests/legacy-cli/e2e/tests/misc/ask-missing-builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async function () {
1414
/Would you like to add a package with "deploy" capabilities/,
1515
);
1616

17-
killAllProcesses();
17+
await killAllProcesses();
1818

1919
// Execute a command with TTY force enabled
2020
execWithEnv('ng', ['lint'], {
@@ -26,6 +26,6 @@ export default async function () {
2626
// Check if the prompt is shown
2727
await waitForAnyProcessOutputToMatch(/Would you like to add ESLint now/);
2828
} finally {
29-
killAllProcesses();
29+
await killAllProcesses();
3030
}
3131
}

0 commit comments

Comments
 (0)