Skip to content

Commit a9e4de1

Browse files
committed
added killBrowser function to terminate hanging Chromium process in 3rd test
1 parent b14926d commit a9e4de1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/svelte-styles-csp/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ describe('svelte-style-csp', async () => {
6767
'svelte-test-transitions-no-styles-csp/index.html'
6868
);
6969
const browser = await puppeteer.launch({ headless: headless_browser });
70+
const process = browser.process();
71+
const killBrowser = (retries = 5) => {
72+
if (retries === 0) {
73+
return; // exit condition
74+
}
75+
if (process && process.pid && process.kill && !process.killed) {
76+
setTimeout(() => {
77+
if (!process.kill('SIGKILL')) {
78+
retries--;
79+
killBrowser(retries);
80+
}
81+
}, 200);
82+
}
83+
};
7084
const page = await browser.newPage();
7185
try {
7286
await page.goto('file://' + absolutePath);
@@ -77,9 +91,10 @@ describe('svelte-style-csp', async () => {
7791
await page.click('input');
7892
} catch (err) {
7993
// Transitions should fail with strict CSP
94+
await browser.close();
8095
assert.throws(err);
8196
}
82-
await browser.close();
97+
killBrowser();
8398
});
8499
});
85100
});

0 commit comments

Comments
 (0)