Skip to content

Commit 87a294d

Browse files
digitalrisedorsetHerve Tribouilloy
andauthored
test: add dummy e2e test to demo package (#356)
Co-authored-by: Herve Tribouilloy <herve@digitalrisedorset.co.uk>
1 parent 910579b commit 87a294d

5 files changed

Lines changed: 42 additions & 0 deletions

File tree

_test/demo-package/Test/e2e/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PLAYWRIGHT_BASE_URL=https://hyva-demo.elgentos.io/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cd e2e
2+
npm install -D @playwright/test
3+
npx playwright install
4+
npm install -D dotenv
5+
npx playwright test hello-magento.spec.ts
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe('Page health checks', () => {
4+
test('Homepage_returns_200', {tag: ['@smoke', '@cold']}, async ({page}) => {
5+
const homepageURL = process.env.PLAYWRIGHT_BASE_URL || process.env.BASE_URL;
6+
if (!homepageURL) {
7+
throw new Error("PLAYWRIGHT_BASE_URL has not been defined in the .env file.");
8+
}
9+
10+
const homepageResponsePromise = page.waitForResponse(homepageURL);
11+
await page.goto(homepageURL);
12+
const homepageResponse = await homepageResponsePromise;
13+
expect(homepageResponse.status(), 'Homepage should return 200').toBe(200);
14+
15+
const pageTtitle = page.getByRole('heading', {level: 1})
16+
17+
await expect(pageTtitle, 'Homepage has a visible title').toBeVisible();
18+
await expect(pageTtitle).toHaveText(/\S+/);
19+
})
20+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from '@playwright/test';
2+
import dotenv from 'dotenv';
3+
4+
dotenv.config();
5+
6+
export default defineConfig({
7+
testDir: '.',
8+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "commonjs",
5+
"strict": true,
6+
"esModuleInterop": true
7+
}
8+
}

0 commit comments

Comments
 (0)