Skip to content

Commit 1cbf8b9

Browse files
authored
Make LaunchedChrome.kill sync (#269)
1 parent 0bd5a5d commit 1cbf8b9

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/chrome-launcher.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface LaunchedChrome {
4646
pid: number;
4747
port: number;
4848
process: ChildProcess;
49-
kill: () => Promise<void>;
49+
kill: () => void;
5050
}
5151

5252
export interface ModuleOverrides {
@@ -72,12 +72,12 @@ async function launch(opts: Options = {}): Promise<LaunchedChrome> {
7272

7373
await instance.launch();
7474

75-
const kill = async () => {
75+
const kill = () => {
7676
instances.delete(instance);
7777
if (instances.size === 0) {
7878
process.removeListener(_SIGINT, sigintListener);
7979
}
80-
return instance.kill();
80+
instance.kill();
8181
};
8282

8383
return {pid: instance.pid!, port: instance.port!, kill, process: instance.chromeProcess!};

test/chrome-launcher-test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('Launcher', () => {
6262

6363
chromeInstance.prepare();
6464

65-
await chromeInstance.destroyTmp();
65+
chromeInstance.destroyTmp();
6666
assert.strictEqual(fs.rmdirSync.callCount, 0);
6767
assert.strictEqual(fs.rmSync.callCount, 0);
6868
});
@@ -105,7 +105,7 @@ describe('Launcher', () => {
105105
const chromeInstance = new Launcher({}, {fs: fs as any});
106106

107107
chromeInstance.prepare();
108-
await chromeInstance.destroyTmp();
108+
chromeInstance.destroyTmp();
109109
assert.strictEqual(rmMock.callCount, 1);
110110
});
111111

@@ -149,14 +149,14 @@ describe('Launcher', () => {
149149
it('doesn\'t fail when killed twice', async () => {
150150
const chromeInstance = new Launcher();
151151
await chromeInstance.launch();
152-
await chromeInstance.kill();
153-
await chromeInstance.kill();
152+
chromeInstance.kill();
153+
chromeInstance.kill();
154154
}).timeout(30 * 1000);
155155

156156
it('doesn\'t fail when killing all instances', async () => {
157157
await launch();
158158
await launch();
159-
const errors = await killAll();
159+
const errors = killAll();
160160
assert.strictEqual(errors.length, 0);
161161
});
162162

@@ -166,7 +166,7 @@ describe('Launcher', () => {
166166
let pid = chromeInstance.pid!;
167167
await chromeInstance.launch();
168168
assert.strictEqual(pid, chromeInstance.pid);
169-
await chromeInstance.kill();
169+
chromeInstance.kill();
170170
});
171171

172172
it('gets all default flags', async () => {

test/launch-signature-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ describe('Launcher', () => {
2626
assert.notStrictEqual(chrome.pid, undefined);
2727
assert.notStrictEqual(chrome.port, undefined);
2828
assert.notStrictEqual(chrome.kill, undefined);
29-
await chrome.kill();
29+
chrome.kill();
3030
});
3131
});

0 commit comments

Comments
 (0)