From 603fa289a93545412ec8eb449cf475c1e0e6923d Mon Sep 17 00:00:00 2001 From: Tony Sullivan Date: Fri, 20 May 2022 23:21:38 -0500 Subject: [PATCH] TEMP: testing typescript tests --- .../e2e/{solid.test.js => solid.test.ts} | 35 +++++++++++-------- packages/astro/package.json | 2 +- packages/astro/playwright.config.ts | 16 +++++++++ 3 files changed, 37 insertions(+), 16 deletions(-) rename packages/astro/e2e/{solid.test.js => solid.test.ts} (80%) create mode 100644 packages/astro/playwright.config.ts diff --git a/packages/astro/e2e/solid.test.js b/packages/astro/e2e/solid.test.ts similarity index 80% rename from packages/astro/e2e/solid.test.js rename to packages/astro/e2e/solid.test.ts index 9e8f49cbc..e299b44ac 100644 --- a/packages/astro/e2e/solid.test.js +++ b/packages/astro/e2e/solid.test.ts @@ -10,23 +10,18 @@ const test = base.extend({ let devServer; -test.beforeAll(async ({ astro }) => { +test.beforeEach(async ({ astro }) => { devServer = await astro.startDevServer(); }); -test.afterAll(async ({ astro }) => { +test.afterEach(async () => { await devServer.stop(); }); -test.afterEach(async ({ astro }) => { - astro.clean(); -}); +test.describe('Solid', () => { + test('server only', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); -test.only('Solid', async ({ page, astro }) => { - page.on('console', msg => console.log('Solid::', msg.text())); - await page.goto(astro.resolveUrl('/')); - - await test.step('server only', async () => { const counter = page.locator('#server-only'); await expect(counter).toBeVisible(); @@ -39,7 +34,9 @@ test.only('Solid', async ({ page, astro }) => { await expect(count).toHaveText('0'); }); - await test.step('client:idle', async () => { + test('client:idle', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + const counter = page.locator('#client-idle'); await expect(counter).toBeVisible(); @@ -52,7 +49,9 @@ test.only('Solid', async ({ page, astro }) => { await expect(count).toHaveText('1'); }); - await test.step('client:load', async () => { + test('client:load', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + const counter = page.locator('#client-load'); await expect(counter).toBeVisible(); @@ -65,7 +64,9 @@ test.only('Solid', async ({ page, astro }) => { await expect(count).toHaveText('1'); }); - await test.step('client:visible', async () => { + test('client:visible', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + const counter = page.locator('#client-visible'); await counter.scrollIntoViewIfNeeded(); await expect(counter).toBeVisible(); @@ -79,7 +80,9 @@ test.only('Solid', async ({ page, astro }) => { await expect(count).toHaveText('1'); }); - await test.step('client:media', async () => { + test('client:media', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + const counter = page.locator('#client-media'); await expect(counter).toBeVisible(); @@ -97,7 +100,9 @@ test.only('Solid', async ({ page, astro }) => { await expect(count).toHaveText('1'); }); - await test.step('HMR', async () => { + test('HMR', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + // test 1: updating the page component await astro.editFile( './src/pages/index.astro', diff --git a/packages/astro/package.json b/packages/astro/package.json index bd594a362..b7b4e551b 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -73,7 +73,7 @@ "benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js", "test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js --ignore **/errors.test.js && mocha --timeout 20000 **/lit-element.test.js && mocha --timeout 20000 **/errors.test.js", "test:match": "mocha --timeout 20000 -g", - "test:e2e": "playwright test e2e", + "test:e2e": "playwright test e2e/*.test.js", "test:e2e:match": "playwright test e2e -g" }, "dependencies": { diff --git a/packages/astro/playwright.config.ts b/packages/astro/playwright.config.ts new file mode 100644 index 000000000..5aff93bca --- /dev/null +++ b/packages/astro/playwright.config.ts @@ -0,0 +1,16 @@ +import type { PlaywrightTestConfig } from '@playwright/test'; + +const config: PlaywrightTestConfig = { + testMatch: 'e2e/*.test.ts', + projects: [ + { + name: 'Chrome Stable', + use: { + browserName: 'chromium', + channel: 'chrome', + }, + }, + ], +}; + +export default config;