You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/testing/usage-instructions.md
+67-3Lines changed: 67 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ E2E tests verify Ionic components in a real browser. This is useful for testing
14
14
15
15
Follow these steps to install Playwright dependencies. These steps must also be run whenever the installed version of Playwright changes to ensure that you are testing with the correct browser binaries.
16
16
17
-
1. Install the Playwright dependency in the `core` directory: `npm ci`
17
+
1. Install the Playwright dependency in the `core` directory: `npm ci`
18
18
2. Download the correct browsers: `npx playwright install`
19
19
20
20
## Configuring Docker
@@ -132,15 +132,79 @@ npm run test.e2e src/components/chip
132
132
```
133
133
134
134
Playwright supports the `--headed` flag to run in headed mode which causes the visual representation of the browser to appear:
135
-
135
+
136
136
```shell
137
137
# Will run tests in headed mode
138
138
npm run test.e2e src/components/chip -- --headed
139
139
```
140
140
141
+
### Debugging Tests
142
+
143
+
Playwright offers several ways to efficiently isolate and debug specific issues, helping to quickly identify and resolve problems within your test suite.
144
+
145
+
#### 1. Running Only Individual Tests
146
+
147
+
The `.only` suffix can be added to individual tests to limit execution to just those tests during debugging. If you add `.only` to a specific test, only that test will be executed, and all other tests in the test suite will be skipped.
148
+
149
+
**Example:**
150
+
151
+
```ts
152
+
test.only('should do something', async ({ page }) => {
153
+
// test code here
154
+
});
155
+
```
156
+
157
+
> [!IMPORTANT]
158
+
> After debugging, make sure to remove the `.only` suffix to ensure all tests run again during normal execution.
159
+
160
+
#### 2. Running Only a Test Suite
161
+
162
+
Similarly, you can focus on an entire test suite by adding `.only` to a `describe` block. This ensures that only the tests within that suite will be executed, while others will be skipped.
163
+
164
+
**Example:**
165
+
166
+
```ts
167
+
test.describe.only('group of tests', () => {
168
+
test('test 1', async ({ page }) => {
169
+
// test 1 code here
170
+
});
171
+
172
+
test('test 2', async ({ page }) => {
173
+
// test 2 code here
174
+
});
175
+
});
176
+
```
177
+
178
+
> [!IMPORTANT]
179
+
> After debugging, make sure to remove the `.only` suffix to ensure all tests run again during normal execution.
180
+
181
+
#### 3. Pausing Test Execution
182
+
183
+
Additionally, you can pause execution of a test by using the `page.pause()` method. This pauses the script execution and allows you to manually inspect the page in the browser.
> After debugging, make sure to remove the `page.pause()` call to restore normal test execution.
204
+
141
205
## Managing Screenshots
142
206
143
-
If you are running a test that takes a screenshot, you must first generate the reference screenshot from your reference branch. This is known as generating a "ground truth screenshot". All other screenshots will be compared to this ground truth.
207
+
If you are running a test that takes a screenshot, you must first generate the reference screenshot from your reference branch. This is known as generating a "ground truth screenshot". All other screenshots will be compared to this ground truth.
144
208
145
209
### Generating or Updating Ground Truths With Docker (Local Development)
0 commit comments