Skip to content

Commit 53fb9bb

Browse files
authored
Merge pull request #2 from Codeuctivity/playwright
testing landing page
2 parents 9393432 + a862a71 commit 53fb9bb

File tree

7 files changed

+194
-6
lines changed

7 files changed

+194
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
fetch-depth: 0
1818
- uses: actions/setup-node@v4
1919
with:
20-
node-version: 20
20+
node-version: lts/*
2121
cache: npm
2222

2323
- name: Install dependencies
24-
run: npm install
24+
run: npm ci
2525
- name: Build website
2626
run: npm run build
2727

@@ -48,4 +48,4 @@ jobs:
4848
steps:
4949
- name: Deploy to GitHub Pages
5050
id: deployment
51-
uses: actions/deploy-pages@v4
51+
uses: actions/deploy-pages@v4

.github/workflows/playwright.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
timeout-minutes: 60
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: lts/*
15+
cache: npm
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Build website
19+
run: (npm run start&)
20+
- name: Install Playwright Browsers
21+
run: npx playwright install --with-deps
22+
- name: Run Playwright tests
23+
run: npx playwright test
24+
- uses: actions/upload-artifact@v4
25+
if: always()
26+
with:
27+
name: playwright-report
28+
path: playwright-report/
29+
retention-days: 30

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
npm-debug.log*
1919
yarn-debug.log*
2020
yarn-error.log*
21+
/test-results/
22+
/playwright-report/
23+
/blob-report/
24+
/playwright/.cache/

package-lock.json

Lines changed: 64 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"@docusaurus/module-type-aliases": "3.2.0",
2828
"@docusaurus/tsconfig": "3.2.0",
2929
"@docusaurus/types": "3.2.0",
30+
"@playwright/test": "^1.42.1",
31+
"@types/node": "^20.12.2",
3032
"typescript": "~5.2.2"
3133
},
3234
"browserslist": {

playwright.config.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// require('dotenv').config();
8+
9+
/**
10+
* See https://playwright.dev/docs/test-configuration.
11+
*/
12+
export default defineConfig({
13+
testDir: './tests',
14+
/* Run tests in files in parallel */
15+
fullyParallel: true,
16+
/* Fail the build on CI if you accidentally left test.only in the source code. */
17+
forbidOnly: !!process.env.CI,
18+
/* Retry on CI only */
19+
retries: process.env.CI ? 2 : 0,
20+
/* Opt out of parallel tests on CI. */
21+
workers: process.env.CI ? 1 : undefined,
22+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
23+
reporter: 'html',
24+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25+
use: {
26+
/* Base URL to use in actions like `await page.goto('/')`. */
27+
baseURL: 'http://localhost:3000/',
28+
29+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
30+
trace: 'on-first-retry',
31+
},
32+
33+
/* Configure projects for major browsers */
34+
projects: [
35+
{
36+
name: 'chromium',
37+
use: { ...devices['Desktop Chrome'] },
38+
},
39+
40+
// {
41+
// name: 'firefox',
42+
// use: { ...devices['Desktop Firefox'] },
43+
// },
44+
45+
// {
46+
// name: 'webkit',
47+
// use: { ...devices['Desktop Safari'] },
48+
// },
49+
50+
/* Test against mobile viewports. */
51+
// {
52+
// name: 'Mobile Chrome',
53+
// use: { ...devices['Pixel 5'] },
54+
// },
55+
// {
56+
// name: 'Mobile Safari',
57+
// use: { ...devices['iPhone 12'] },
58+
// },
59+
60+
/* Test against branded browsers. */
61+
// {
62+
// name: 'Microsoft Edge',
63+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
64+
// },
65+
// {
66+
// name: 'Google Chrome',
67+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
68+
// },
69+
],
70+
71+
/* Run your local dev server before starting the tests */
72+
// webServer: {
73+
// command: 'npm run start',
74+
// url: 'http://127.0.0.1:3000',
75+
// reuseExistingServer: !process.env.CI,
76+
// },
77+
});

tests/landingpage.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('/');
5+
6+
// Expect a title "to contain" a substring.
7+
await expect(page).toHaveTitle(/Hello from codeuctivity/);
8+
});
9+
10+
test('get text of landing page', async ({ page }) => {
11+
await page.goto('/');
12+
13+
await expect(page.locator('h1')).toContainText('codeuctivity');
14+
await expect(page.getByRole('banner')).toContainText('Turning Coffee into Code: A Journey of Joyful Creation');
15+
});

0 commit comments

Comments
 (0)