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: chapter_10.md
+76-63
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
-
Visual Regression Testing
2
-
=========================
1
+
# Visual Regression Testing
3
2
4
3
To walk through the advanced features, we will start with a clean project. This approach ensures that we have a controlled environment for our tests.
5
4
With this new project, we'll delve into the capabilities of the WebdriverIO testrunner, focusing on its integration with the [`@wdio/visual-service`](https://github.com/webdriverio/visual-testing). This service, designed specifically for WebdriverIO, accommodates a variety of testing environments, including:
@@ -14,11 +13,11 @@ Our objectives for Visual Testing include:
3. Rerun the test: `npm run wdio -- --spec="test/specs/desktop.spec.ts"`.
@@ -111,9 +116,10 @@ The Visual Testing module uses pixel-by-pixel comparison, which can lead to fals
111
116
-[`enableLayoutTesting`-service](https://webdriver.io/docs/visual-testing/service-options#enablelayouttesting) option, which makes all text on a page transparent, including font-based icons.
112
117
-[`enableLayoutTesting`-method](https://webdriver.io/docs/visual-testing/method-options#enablelayouttesting) option, applying transparency only to text in specific methods.
113
118
114
-
Experiment with these options and rerun your tests: `npm run wdio -- --spec="test/specs/desktop.spec.ts"`.
119
+
Experiment with these options and rerun your tests: `npm run wdio -- --spec="test/specs/desktop.spec.ts"`.
115
120
116
121
## Extra 1: Storybook Testing
122
+
117
123
Now, we will combine WebdriverIO and the Visual Testing Module with both locally and externally hosted Storybook instances.
118
124
119
125
> [!TIP]
@@ -187,14 +193,14 @@ info Using tsconfig paths for react-docgen
187
193
188
194
</details>
189
195
190
-
191
196
3. After successful installation, Storybook will automatically open in your browser. You will see several components (Button/Header/Page).
192
197
4. Start Storybook Visual Testing with `npx wdio ./wdio.conf.ts --storybook`. This creates `.tmp` and `__snapshots__` folders, both at the root of the project, with relevant images.
193
198
5. The images have automatically been clipped to the "estimated" size of the component. If you want you can also:
194
-
- select the [browsers](https://github.com/webdriverio/visual-testing/tree/main?tab=readme-ov-file#--browsers) by adding `--browsers=chrome,firefox`
195
-
- select an [emulated device mode](https://github.com/webdriverio/visual-testing/tree/main?tab=readme-ov-file#--devices) by for example providing for example `--devices="iPhone 14 Pro Max","Pixel 3 XL"` to the command.
199
+
- select the [browsers](https://github.com/webdriverio/visual-testing/tree/main?tab=readme-ov-file#--browsers) by adding `--browsers=chrome,firefox`
200
+
- select an [emulated device mode](https://github.com/webdriverio/visual-testing/tree/main?tab=readme-ov-file#--devices) by for example providing for example `--devices="iPhone 14 Pro Max","Pixel 3 XL"` to the command.
196
201
197
202
> [!TIP]
203
+
>
198
204
> - If you want to see what is happening then provide `--headless=false` to the command line so the test will run in "normal" mode
199
205
> - By default snapshots will be clipped. By providing `--clip=false` as an extra argument the "full"-screen snapshot will be taken. This can come in handy when using the `--devices` argument
200
206
@@ -221,34 +227,37 @@ Finally, let's apply the Visual Testing service to Mobile Native apps.
221
227
1. Follow the instructions to install [`appium-installer`](https://github.com/AppiumTestDistribution/appium-installer)
222
228
2. Open a new terminal and execute `appium-installer`, following the necessary steps.
223
229
224
-
-*Need help setting up Android Environment to run your Appium test?*
225
-
-*Install Appium Server*
226
-
-*Install Appium Drivers*
227
-
-*Run Appium Doctor*
230
+
-_Need help setting up Android Environment to run your Appium test?_
231
+
-_Install Appium Server_
232
+
-_Install Appium Drivers_
233
+
-_Run Appium Doctor_
228
234
229
235
3. Start Appium with `appium server --log-timestamp --relaxed-security`. Keep this terminal open.
230
236
4. Create an `apps` folder at your project's root and download the required Android or iOS app from [here](https://github.com/webdriverio/native-demo-app/releases).
231
237
5. Create a file named `wdio.android.emulator.conf.ts` in the root of your project with the following contents:
0 commit comments