Skip to content

Commit 90f5a01

Browse files
Update TESTING.md
1 parent 2d9107b commit 90f5a01

File tree

1 file changed

+5
-74
lines changed

1 file changed

+5
-74
lines changed

TESTING.md

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ npx playwright install
111111
Playwright tests are written using the Playwright Test framework. Here's a basic example:
112112

113113
```typescript
114-
// e2e/example.spec.ts
115114
import { test, expect } from '@playwright/test';
116115

117116
test('basic test', async ({ page }) => {
@@ -134,29 +133,13 @@ test('basic test', async ({ page }) => {
134133
To run all Playwright tests:
135134

136135
```bash
137-
npx playwright test
136+
yarn playwright:test
138137
```
139138

140139
To run a specific test file:
141140

142141
```bash
143-
npx playwright test e2e/example.spec.ts
144-
```
145-
146-
To run tests in headed mode (with browser visible):
147-
148-
```bash
149-
npx playwright test --headed
150-
```
151-
152-
To run tests in a specific browser:
153-
154-
```bash
155-
npx playwright test --browser=chromium
156-
# or
157-
npx playwright test --browser=firefox
158-
# or
159-
npx playwright test --browser=webkit
142+
yarn playwright:test tests/basic-tests.spec.ts
160143
```
161144

162145
### Debugging Playwright Tests
@@ -166,7 +149,7 @@ To debug tests:
166149
1. Run with the `--debug` flag:
167150

168151
```bash
169-
npx playwright test --debug
152+
yarn playwright:test --debug
170153
```
171154

172155
2. Use the Playwright Inspector to step through the test.
@@ -178,65 +161,13 @@ npx playwright test --debug
178161
To generate an HTML report:
179162

180163
```bash
181-
npx playwright test --reporter=html
164+
yarn playwright:test --reporter=html
182165
```
183166

184167
Then open the report:
185168

186169
```bash
187-
npx playwright show-report
188-
```
189-
190-
### Testing Mobile Web Views
191-
192-
For testing mobile web views:
193-
194-
```typescript
195-
test('mobile view test', async ({ browser }) => {
196-
// Create a new context with mobile device emulation
197-
const context = await browser.newContext({
198-
viewport: { width: 375, height: 667 },
199-
userAgent:
200-
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1'
201-
});
202-
203-
const page = await context.newPage();
204-
// Continue with your test...
205-
});
206-
```
207-
208-
### CI Integration
209-
210-
Playwright tests can be integrated into your CI pipeline. Here's an example GitHub Actions workflow:
211-
212-
```yaml
213-
name: Playwright Tests
214-
on:
215-
push:
216-
branches: [main, master]
217-
pull_request:
218-
branches: [main, master]
219-
jobs:
220-
test:
221-
timeout-minutes: 60
222-
runs-on: ubuntu-latest
223-
steps:
224-
- uses: actions/checkout@v3
225-
- uses: actions/setup-node@v3
226-
with:
227-
node-version: 16
228-
- name: Install dependencies
229-
run: yarn install
230-
- name: Install Playwright Browsers
231-
run: npx playwright install --with-deps
232-
- name: Run Playwright tests
233-
run: npx playwright test
234-
- uses: actions/upload-artifact@v3
235-
if: always()
236-
with:
237-
name: playwright-report
238-
path: playwright-report/
239-
retention-days: 30
170+
yarn playwright:test show-report
240171
```
241172

242173
For more information, refer to the [Playwright documentation](https://playwright.dev/docs/intro).

0 commit comments

Comments
 (0)