@@ -35,6 +35,7 @@
|
||||
"fs-extra": "9.1.0",
|
||||
"handlebars": "^4.7.3",
|
||||
"pgtools": "^0.3.0",
|
||||
"puppeteer": "^10.4.0",
|
||||
"tree-kill": "^1.2.2",
|
||||
"ts-node": "^10.0.0"
|
||||
},
|
||||
@@ -42,8 +43,5 @@
|
||||
"watch": "./src",
|
||||
"exec": "bin/e2e-test",
|
||||
"ext": "ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"puppeteer": "^10.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,14 +352,16 @@ async function testAppServe(pluginName: string, appDir: string) {
|
||||
},
|
||||
});
|
||||
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto('http://localhost:3000');
|
||||
|
||||
let successful = false;
|
||||
|
||||
let browser;
|
||||
try {
|
||||
for (let attempts = 1; ; attempts++) {
|
||||
try {
|
||||
browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto('http://localhost:3000');
|
||||
|
||||
await waitForPageWithText(page, '/', 'My Company Catalog');
|
||||
await waitForPageWithText(
|
||||
page,
|
||||
@@ -380,6 +382,7 @@ async function testAppServe(pluginName: string, appDir: string) {
|
||||
}
|
||||
} finally {
|
||||
// Kill entire process group, otherwise we'll end up with hanging serve processes
|
||||
if (browser) await browser.close();
|
||||
killTree(startApp.pid);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,13 +141,15 @@ export async function waitForPageWithText(
|
||||
await page.goto(`http://localhost:3000${path}`);
|
||||
|
||||
const escapedText = text.replace(/"|\\/g, '\\$&');
|
||||
await expect(() =>
|
||||
page.evaluate(() =>
|
||||
Array.from(document.querySelectorAll('*')).some(
|
||||
el => el.textContent === escapedText,
|
||||
),
|
||||
const match = await page.evaluate(() =>
|
||||
Array.from(document.querySelectorAll('*')).some(
|
||||
el => el.textContent === escapedText,
|
||||
),
|
||||
).resolves.toBeTruthy();
|
||||
);
|
||||
|
||||
if (!match) {
|
||||
throw new Error(`Expected to find text ${escapedText}`);
|
||||
}
|
||||
|
||||
break;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user