Skip to content

Commit a6d86aa

Browse files
committed
test: βœ… set up playwright
1 parent 0737f6e commit a6d86aa

File tree

5 files changed

+96
-8
lines changed

5 files changed

+96
-8
lines changed

β€Žapps/404-recipe-filter-material-starter/.eslintrc.jsonβ€Ž

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2-
"extends": ["plugin:playwright/recommended", "../../.eslintrc.json"],
2+
"extends": [
3+
"plugin:playwright/recommended",
4+
"plugin:playwright/recommended",
5+
"../../.eslintrc.json"
6+
],
37
"ignorePatterns": [
48
"!**/*",
59
"playwright/.cache/**/*",
@@ -42,6 +46,10 @@
4246
{
4347
"files": ["**/*.pw.{ts,js,tsx,jsx}"],
4448
"rules": {}
49+
},
50+
{
51+
"files": ["e2e/**/*.{ts,js,tsx,jsx}"],
52+
"rules": {}
4553
}
4654
]
4755
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('/');
5+
6+
// Expect h1 to contain a substring.
7+
expect(await page.locator('h1').innerText()).toContain('Welcome');
8+
});
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
import { nxE2EPreset } from '@nx/playwright/preset';
3+
import { workspaceRoot } from '@nx/devkit';
4+
5+
// For CI, you may want to set BASE_URL to the deployed application.
6+
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
7+
8+
/**
9+
* Read environment variables from file.
10+
* https://github.com/motdotla/dotenv
11+
*/
12+
// require('dotenv').config();
13+
14+
/**
15+
* See https://playwright.dev/docs/test-configuration.
16+
*/
17+
export default defineConfig({
18+
...nxE2EPreset(__filename, { testDir: './e2e' }),
19+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
20+
use: {
21+
baseURL,
22+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
23+
trace: 'on-first-retry',
24+
},
25+
/* Run your local dev server before starting the tests */
26+
webServer: [
27+
{
28+
command: 'npx nx serve 404-recipe-filter-material-starter',
29+
url: 'http://localhost:4200',
30+
reuseExistingServer: true,
31+
cwd: workspaceRoot,
32+
},
33+
],
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+
// Uncomment for mobile browsers support
51+
/* {
52+
name: 'Mobile Chrome',
53+
use: { ...devices['Pixel 5'] },
54+
},
55+
{
56+
name: 'Mobile Safari',
57+
use: { ...devices['iPhone 12'] },
58+
}, */
59+
60+
// Uncomment for 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+
});

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"dotenv": "10.0.0",
8181
"eslint": "8.57.0",
8282
"eslint-config-prettier": "10.1.8",
83-
"eslint-plugin-playwright": "^0.15.3",
83+
"eslint-plugin-playwright": "^1.6.2",
8484
"file-loader": "^6.2.0",
8585
"html-webpack-plugin": "^5.6.0",
8686
"jest": "30.0.5",

β€Žpnpm-lock.yamlβ€Ž

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

0 commit comments

Comments
Β (0)