Skip to content

Commit aef5517

Browse files
initialize playwright (#98)
1 parent 0b32de4 commit aef5517

File tree

7 files changed

+629
-1
lines changed

7 files changed

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

src/ContosoTraders.Ui.Website/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ npm-debug.log*
2020
yarn-debug.log*
2121
yarn-error.log*
2222

23-
appsettings.Development.json
23+
appsettings.Development.json
24+
/test-results/
25+
/playwright-report/
26+
/playwright/.cache/

src/ContosoTraders.Ui.Website/package-lock.json

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

src/ContosoTraders.Ui.Website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"not op_mini all"
6666
],
6767
"devDependencies": {
68+
"@playwright/test": "^1.29.0",
6869
"babel-plugin-macros": "^2.8.0"
6970
}
7071
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// @ts-check
2+
const { devices } = require('@playwright/test');
3+
4+
/**
5+
* Read environment variables from file.
6+
* https://github.com/motdotla/dotenv
7+
*/
8+
// require('dotenv').config();
9+
10+
11+
/**
12+
* @see https://playwright.dev/docs/test-configuration
13+
* @type {import('@playwright/test').PlaywrightTestConfig}
14+
*/
15+
const config = {
16+
testDir: './tests',
17+
/* Maximum time one test can run for. */
18+
timeout: 30 * 1000,
19+
expect: {
20+
/**
21+
* Maximum time expect() should wait for the condition to be met.
22+
* For example in `await expect(locator).toHaveText();`
23+
*/
24+
timeout: 5000
25+
},
26+
/* Run tests in files in parallel */
27+
fullyParallel: true,
28+
/* Fail the build on CI if you accidentally left test.only in the source code. */
29+
forbidOnly: !!process.env.CI,
30+
/* Retry on CI only */
31+
retries: process.env.CI ? 2 : 0,
32+
/* Opt out of parallel tests on CI. */
33+
workers: process.env.CI ? 1 : undefined,
34+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
35+
reporter: 'html',
36+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
37+
use: {
38+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
39+
actionTimeout: 0,
40+
/* Base URL to use in actions like `await page.goto('/')`. */
41+
// baseURL: 'http://localhost:3000',
42+
43+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
44+
trace: 'on-first-retry',
45+
},
46+
47+
/* Configure projects for major browsers */
48+
projects: [
49+
{
50+
name: 'chromium',
51+
use: {
52+
...devices['Desktop Chrome'],
53+
},
54+
},
55+
56+
{
57+
name: 'firefox',
58+
use: {
59+
...devices['Desktop Firefox'],
60+
},
61+
},
62+
63+
{
64+
name: 'webkit',
65+
use: {
66+
...devices['Desktop Safari'],
67+
},
68+
},
69+
70+
/* Test against mobile viewports. */
71+
// {
72+
// name: 'Mobile Chrome',
73+
// use: {
74+
// ...devices['Pixel 5'],
75+
// },
76+
// },
77+
// {
78+
// name: 'Mobile Safari',
79+
// use: {
80+
// ...devices['iPhone 12'],
81+
// },
82+
// },
83+
84+
/* Test against branded browsers. */
85+
// {
86+
// name: 'Microsoft Edge',
87+
// use: {
88+
// channel: 'msedge',
89+
// },
90+
// },
91+
// {
92+
// name: 'Google Chrome',
93+
// use: {
94+
// channel: 'chrome',
95+
// },
96+
// },
97+
],
98+
99+
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
100+
// outputDir: 'test-results/',
101+
102+
/* Run your local dev server before starting the tests */
103+
// webServer: {
104+
// command: 'npm run start',
105+
// port: 3000,
106+
// },
107+
};
108+
109+
module.exports = config;

0 commit comments

Comments
 (0)