diff --git a/test/helpers.js b/test/helpers.js index c4eee6f433..1382af0691 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -331,67 +331,3 @@ export function prettyPrintPuppeteerAssertionError(message) { assert.equal(match[1], match[2]); } } - -/** - * - * @param {() => Promise} fn - * @param {number} maxAttempts - * @param {number} interval - * @returns {Promise} - */ -export async function retryAsync(fn, maxAttempts = 3, interval = 1000) { - let attempts = 0; - while (attempts <= maxAttempts) { - try { - return await fn(); - } catch (err) { - if (++attempts >= maxAttempts) throw err; - await new Promise((resolve) => setTimeout(resolve, interval)); - } - } -} - -/** - * NOTE: Chromium may exit with SIGSEGV, so retry in that case - * @param {import ('puppeteer').Browser} browser - * @param {() => Promise} launchPuppeteer - * @param {() => void} additionalAssertion - * @param {(err: Error) => void} onError - * @returns {Promise} - */ -export async function executeBrowserTest(browser, launchPuppeteer, additionalAssertion, onError) { - let count = 0; - do { - count++; - try { - const page = await browser.newPage(); - - page.on('console', (type) => { - console[type.type()](type.text()); - }); - - page.on('pageerror', (error) => { - console.log('>>> an error happened'); - console.error(error); - }); - await page.goto('http://localhost:6789'); - const result = await page.evaluate(() => { - // @ts-ignore -- It runs in browser context. - return test(document.querySelector('main')); - }); - if (result) console.log(result); - additionalAssertion(); - await page.close(); - break; - } catch (err) { - if (count === 5 || browser.isConnected()) { - onError(err); - throw err; - } - console.debug(err.stack || err); - console.log('RESTARTING Chromium...'); - browser = await launchPuppeteer(); - } - } while (count <= 5); - return browser; -} diff --git a/test/runtime-puppeteer/index.js b/test/runtime-puppeteer/index.js index 9d60650a7f..88ba9dd866 100644 --- a/test/runtime-puppeteer/index.js +++ b/test/runtime-puppeteer/index.js @@ -15,13 +15,13 @@ const index = path.resolve('index.mjs'); const assert = fs.readFileSync(`${__dirname}/assert.js`, 'utf-8'); -describe('runtime (puppeteer)', () => { +describe('runtime (playwright)', () => { before(async () => { svelte = loadSvelte(false); - console.log('[runtime-puppeteer] Loaded Svelte'); + console.log('[runtime-playwright] Loaded Svelte'); browser = await chromium.launch(); - console.log('[runtime-puppeteer] Launched puppeteer browser'); + console.log('[runtime-playwright] Launchedplaywrightr browser'); }); after(async () => { @@ -57,7 +57,7 @@ describe('runtime (puppeteer)', () => { input: 'main', plugins: [ { - name: 'testing-runtime-puppeteer', + name: 'testing-runtime-playwright', resolveId(importee) { if (importee === 'svelte/internal' || importee === './internal') { return internal; diff --git a/test/runtime-puppeteer/samples/component-event-handler-contenteditable-false/_config.js b/test/runtime-puppeteer/samples/component-event-handler-contenteditable-false/_config.js index d7f9da9dba..f13e655805 100644 --- a/test/runtime-puppeteer/samples/component-event-handler-contenteditable-false/_config.js +++ b/test/runtime-puppeteer/samples/component-event-handler-contenteditable-false/_config.js @@ -1,4 +1,4 @@ -// A puppeteer test because JSDOM doesn't support contenteditable +// A playwright test because JSDOM doesn't support contenteditable export default { html: '
', diff --git a/test/runtime-puppeteer/samples/component-event-handler-contenteditable-spread/_config.js b/test/runtime-puppeteer/samples/component-event-handler-contenteditable-spread/_config.js index 7acd8a0b3d..4ccf59ec47 100644 --- a/test/runtime-puppeteer/samples/component-event-handler-contenteditable-spread/_config.js +++ b/test/runtime-puppeteer/samples/component-event-handler-contenteditable-spread/_config.js @@ -1,4 +1,4 @@ -// A puppeteer test because JSDOM doesn't support contenteditable +// A playwright test because JSDOM doesn't support contenteditable export default { html: '
', ssrHtml: '
', diff --git a/test/runtime-puppeteer/samples/component-event-handler-contenteditable/_config.js b/test/runtime-puppeteer/samples/component-event-handler-contenteditable/_config.js index 63344bf3d3..b58936e675 100644 --- a/test/runtime-puppeteer/samples/component-event-handler-contenteditable/_config.js +++ b/test/runtime-puppeteer/samples/component-event-handler-contenteditable/_config.js @@ -1,4 +1,4 @@ -// A puppeteer test because JSDOM doesn't support contenteditable +// A playwright test because JSDOM doesn't support contenteditable export default { html: '
',