Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug windows e2e tests #921

Merged
merged 12 commits into from
Aug 25, 2024
12 changes: 5 additions & 7 deletions tests/e2e/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const beforeStart = (timeout) => new Promise(async (resolve, reject) => {
process.stdout.on('data', handleOutput);
process.stderr.on('data', handleOutput);
process.on('close', (code) => console.log(`[electron] Exited with code ${code}`));
await sleep(timeout) // Wait for five seconds for Electron to open
await sleep(timeout)

reject('Failed to open Electron window successfully.')
})
Expand All @@ -33,15 +33,13 @@ type BrowserTestOutput = {
browser?: puppeteer.Browser,
}

const beforeStartTimeout = 60 * 1000 // Wait for 1 minute for Electron to open (mostly for Windows)
const launchProtocolTimeout = 6 * 60 * 1000 // Creating the test dataset can take up to 6 minutes (mostly for Windows)
const beforeStartTimeout = 2 * 60 * 1000 // Wait 2 minutes for Electron to open
const protocolTimeout = 10 * 60 * 1000 // Creating the test dataset can take up to 10 minutes (mostly for Windows)

export const connect = () => {


const output: BrowserTestOutput = {}


beforeAll(async () => {

await beforeStart(beforeStartTimeout)
Expand All @@ -52,7 +50,7 @@ export const connect = () => {
});

const browserURL = `http://localhost:${electronDebugPort}`
const browser = output.browser = await puppeteer.launch({ headless: 'new', protocolTimeout: launchProtocolTimeout})
const browser = output.browser = await puppeteer.launch({ headless: 'new' })
const page = output.page = await browser.newPage();
await page.goto(browserURL);
const endpoint = await page.evaluate(() => fetch(`json/version`).then(res => res.json()).then(res => res.webSocketDebuggerUrl))
Expand All @@ -62,7 +60,7 @@ export const connect = () => {

// Connect to browser WS Endpoint
const browserWSEndpoint = endpoint.replace('localhost', '0.0.0.0')
output.browser = await puppeteer.connect({ browserWSEndpoint, defaultViewport: null })
output.browser = await puppeteer.connect({ browserWSEndpoint, defaultViewport: null, protocolTimeout: protocolTimeout})

const pages = await output.browser.pages()
output.page = pages[0]
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/tutorial.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ describe('E2E Test', () => {

const datasetTestFunction = config.regenerateTestData ? test : test.skip

datasetTestFunction('Create tutorial dataset', async () => {
// Wait up to 10 minutes for dataset generation
// Both the test timeout and the protocolTimeout on puppeteer.connect() must be set to 10 min
datasetTestFunction('Create tutorial dataset', { timeout: 10 * 60 * 1000 }, async () => {

await evaluate(async () => {

Expand Down
Loading