Skip to content

Commit caaa0e5

Browse files
feat: Initialize Playwright testing (#12)
Co-authored-by: Eugene Yu <Eugene.Yu@dynamsoft.com>
1 parent 7d6729d commit caaa0e5

File tree

8 files changed

+1004
-3
lines changed

8 files changed

+1004
-3
lines changed

.github/workflows/playwright.yml

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@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm i
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: npm test
22+
- uses: actions/upload-artifact@v4
23+
if: always()
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CaptureImageModal
1212
npm-debug.log*
1313
yarn-debug.log*
1414
yarn-error.log*
15+
CaptureImageModal
1516

1617
# Editor directories and files
1718
.idea
@@ -26,7 +27,6 @@ __pycache__
2627
~~*
2728
--*
2829
==*
29-
package-lock.json
3030
yarn.lock
3131
.git
3232
.npmrc
@@ -35,12 +35,14 @@ yarn.lock
3535
/*.exe
3636
/*.jar
3737
/*.md
38-
/*.json
3938
/*.js
4039
/*.txt
4140
/.gitattributes
4241
/.*ignore
4342

4443
!bower.json
4544
!composer.json
46-
!package.js
45+
/test-results/
46+
/playwright-report/
47+
/blob-report/
48+
/playwright/.cache/

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,33 @@
1010

1111
You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense/?product=cvs&utm_source=github&package=js) link.
1212

13+
## Testing
14+
15+
This repository also includes end-to-end tests for each samples using [Playwright](https://playwright.dev/). The tests are organized per sample, and the setup supports cross-browser testing across Chromium, Firefox, and WebKit.
16+
17+
### Installation
18+
19+
``` bash
20+
npm install
21+
npx playwright install --with-deps # installs playwright browsers
22+
```
23+
24+
### Running Tests
25+
26+
```bash
27+
npx playwright test # or `npm test`
28+
```
29+
30+
### View Test Reports
31+
32+
```bas
33+
npx playwright show-report
34+
```
35+
36+
### CI Integration
37+
38+
This repository is set up to run tests automatically on each commit via CI Github Actions. To learn more, visit https://playwright.dev/docs/ci-intro.
39+
1340
## Contact Us
1441

1542
[https://www.dynamsoft.com/company/contact/](https://www.dynamsoft.com/company/contact/?product=cvs&utm_source=github&package=js)

VINScanner/tests/index.spec.ts

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("load local page", async ({ page }) => {
4+
await page.goto("/VINScanner/index.html");
5+
6+
// Expects page to have a heading with the name of Installation.
7+
await expect(await page.title()).toContain("VIN Scanner");
8+
});
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("load local page", async ({ page }) => {
4+
await page.goto("/VINScanner/minimum-elements.html");
5+
6+
// Expects page to have a heading with the name of Installation.
7+
await expect(await page.title()).toContain("VIN Scanner - Minimum elements");
8+
});

0 commit comments

Comments
 (0)