Skip to content

Commit 3ff3fb4

Browse files
authored
Merge pull request #205 from Front-End-Coders-Mauritius/nuxt-playwright
Move the tests in nuxt instead of astro
2 parents 049206e + 4b53c51 commit 3ff3fb4

File tree

6 files changed

+137
-31
lines changed

6 files changed

+137
-31
lines changed

.github/workflows/playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131

3232
- name: Run Playwright tests
3333
run: |
34-
pnpm run astro test
34+
pnpm run nuxt test

packages/frontendmu-nuxt/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"preview": "nuxt preview",
1010
"postinstall": "nuxt prepare",
1111
"lint": "eslint .",
12-
"lint:fix": "eslint . --fix"
12+
"lint:fix": "eslint . --fix",
13+
"test": "playwright test",
14+
"codegen": "playwright codegen"
1315
},
1416
"dependencies": {
1517
"@nuxt/fonts": "^0.7.1",
@@ -35,6 +37,7 @@
3537
"@antfu/eslint-config": "^2.24.1",
3638
"@nuxt/eslint": "^0.4.0",
3739
"@nuxtjs/tailwindcss": "^6.12.1",
40+
"@playwright/test": "^1.40.1",
3841
"eslint": "^9.8.0",
3942
"typescript": "^5.5.4"
4043
}
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: 'pnpm run dev',
74+
url: 'http://localhost:3000',
75+
reuseExistingServer: !process.env.CI,
76+
},
77+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('/');
5+
await expect(page).toHaveTitle(/Front-End Coders Mauritius/);
6+
});
7+
8+
9+
test('upcoming meetups visible', async ({ page }) => {
10+
await page.goto('/');
11+
await expect(page.getByRole('heading', { name: 'Upcoming Meetups' })).toBeVisible();
12+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('sandeep pages', async ({ page }) => {
4+
await page.goto('/');
5+
await page.getByText('View all meetups').first().click();
6+
await expect(page.locator('h1').first()).toContainText('All meetups');
7+
await page.goto('/team');
8+
await page.getByTitle('Sandeep Ramgolam').first().click(); // Go to the speaker page for Sandeep Ramgolam
9+
await page.getByRole('link', { name: 'Sat May 20 2023 Git, CVs &' }).click(); // Go to the meetup page for Git, CVs & getting in to tech
10+
await expect(page.getByRole('heading', { name: 'Git, CVs & getting in to tech' })).toBeVisible(); // Check that we are on the right page
11+
});

0 commit comments

Comments
 (0)