Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ $ npm i --save-dev puppeteer@^19.11.1
$ TEST_BROWSER_DRIVER=puppeteer meteor test --once --driver-package <your package name>
```

Use `PUPPETEER_WAIT_TIMEOUT` env to set wait timeout in milliseconds after which the driver will forcefully stop running the tests (default is 30 minutes).

### Playwright

`playwright@^1.33.0` is the latest version with Node 14 compatibility (Meteor 2.x is set to use Node.js version 14.x by default).
Expand Down
16 changes: 14 additions & 2 deletions browser/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
*/
const util = require('util');

// 30 minutes by default
const WAIT_TIMEOUT = process.env.PUPPETEER_WAIT_TIMEOUT
? Number.parseInt(process.env.PUPPETEER_WAIT_TIMEOUT, 10)
: 30 * 60 * 1000;

if (Number.isNaN(WAIT_TIMEOUT)) {
throw new Error(`Invalid PUPPETEER_WAIT_TIMEOUT value: ${process.env.PUPPETEER_WAIT_TIMEOUT}`);
}

export default function startPuppeteer({
stdout,
stderr,
Expand Down Expand Up @@ -63,7 +72,7 @@ export default function startPuppeteer({

await page.goto(process.env.ROOT_URL);

await page.waitForFunction(() => window.testsDone, { timeout: 0 });
await page.waitForFunction(() => window.testsDone, { timeout: WAIT_TIMEOUT });
const testFailures = await page.evaluate('window.testFailures');

await consolePromise;
Expand All @@ -73,5 +82,8 @@ export default function startPuppeteer({
done(testFailures);
}

runTests();
runTests().catch(err => {
stderr(err);
done();
});
}