mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
test: puppeteer auto close
This commit is contained in:
@@ -18,10 +18,10 @@ module.exports = async () => {
|
||||
browser = await puppeteer.launch(options);
|
||||
}
|
||||
setTimeout(async () => {
|
||||
if ((await browser.process()).signalCode) {
|
||||
if ((await browser.process()).exitCode === null) {
|
||||
browser.close();
|
||||
}
|
||||
}, 5000);
|
||||
}, 10000);
|
||||
|
||||
return browser;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
const puppeteer = require('../../lib/utils/puppeteer');
|
||||
const wait = require('../../lib/utils/wait');
|
||||
|
||||
describe('puppeteer', () => {
|
||||
it('puppeteer run', async () => {
|
||||
const browser = await puppeteer();
|
||||
const page = await browser.newPage();
|
||||
await page.goto('https://github.com/DIYgod/RSSHub', {
|
||||
await page.goto('https://www.google.com', {
|
||||
waitUntil: 'domcontentloaded',
|
||||
});
|
||||
|
||||
@@ -12,6 +13,8 @@ describe('puppeteer', () => {
|
||||
const html = await page.evaluate(() => document.body.innerHTML);
|
||||
expect(html.length).toBeGreaterThan(0);
|
||||
|
||||
await browser.close();
|
||||
}, 10000);
|
||||
expect((await browser.process()).exitCode).toBe(null);
|
||||
await wait(10 * 1000);
|
||||
expect((await browser.process()).exitCode).toBe(0);
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user