Skip to content

Commit 701cec5

Browse files
authored
first steps frontend testing with playwright (#17)
1 parent e93b84d commit 701cec5

File tree

7 files changed

+655
-12
lines changed

7 files changed

+655
-12
lines changed

.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+
branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm ci
18+
run: npm run clone
19+
run: npm run unit
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ abap2UI5
44
abap2UI5-samples
55
output
66
src
7-
build
7+
build
8+
/test-results/
9+
/playwright-report/
10+
/blob-report/
11+
/playwright/.cache/

package-lock.json

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

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,21 @@
2626
"homepage": "https://github.com/abap2UI5/abap2UI5-web#readme",
2727
"devDependencies": {
2828
"@abaplint/cli": "^2.110.2",
29-
"@abaplint/runtime": "^2.8.27",
3029
"@abaplint/database-sqlite": "^2.8.25",
31-
"express": "^4.19.2",
30+
"@abaplint/runtime": "^2.8.27",
3231
"@abaplint/transpiler-cli": "^2.8.27",
32+
"@playwright/test": "^1.47.0",
33+
"@types/node": "^22.5.4",
3334
"buffer": "^6.0.3",
34-
"web-encoding": "^1.1.5",
3535
"copy-webpack-plugin": "^12.0.2",
36+
"express": "^4.19.2",
3637
"html-webpack-plugin": "^5.6.0",
3738
"path-browserify": "^1.0.1",
39+
"web-encoding": "^1.1.5",
3840
"webpack-cli": "^5.1.4",
3941
"webpack-dev-server": "^5.0.4"
42+
},
43+
"dependencies": {
44+
"playwright": "^1.47.0"
4045
}
4146
}

playwright.config.js

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

0 commit comments

Comments
 (0)