2
2
3
3
## 🧠You will learn
4
4
5
- ✅What is visual E2E testing?
5
+ ✅What is visual E2E testing?
6
6
7
7
✅How to implement visual e2e testing for a web app
8
8
16
16
17
17
---
18
18
19
- <img src =" ./../../../graphics/visual-testing.png " alt =" visual-testing " width =" 500 " />
20
-
21
- <img src =" ./../../../graphics/visual-workflow.jpeg " alt =" visual-testing " width =" 500 " />
19
+ [ Let's take a look] ( visual-testing.pdf )
22
20
23
21
### Advantages of visual tests
24
22
32
30
33
31
✅ Can help reduce the size of e2e suite
34
32
35
- [ Deeper discussion of visual testing] ( https://docs.google.com/presentation/d/13jYXXoKb36aFt1HLnNnAmsPqw9yaFhVrB4iFH_5_WkI/edit#slide=id.gcc181d5a54_0_284 )
36
-
37
33
## Our tools
38
34
39
35
### [ WebdriverIO] ( https://webdriver.io/ )
36
+
40
37
Next-gen browser and mobile automation test framework for Node.js
41
38
42
39
### [ Screener] ( https://screener.io/ )
40
+
43
41
Automatically detect visual regressions across your UI
44
42
45
43
## Set up a visual test
@@ -50,22 +48,21 @@ follow along
50
48
2 . Paste the following code
51
49
52
50
``` javascript
53
-
54
51
describe (' My app' , () => {
55
- it (' should look correct' , async () => {
56
- await browser .url (' ' );
57
- await browser .execute (' /*@visual.init*/' , ' My React App' );
58
- await browser .execute (' /*@visual.snapshot*/' , ' Home Page' );
59
-
60
- const result = await browser .execute (' /*@visual.end*/' );
61
- expect (result .message ).toBeNull ();
62
- });
52
+ it (' should look correct' , async () => {
53
+ await browser .url (' ' );
54
+ await browser .execute (' /*@visual.init*/' , ' My React App' );
55
+ await browser .execute (' /*@visual.snapshot*/' , ' Home Page' );
56
+
57
+ const result = await browser .execute (' /*@visual.end*/' );
58
+ expect (result .message ).toBeNull ();
59
+ });
63
60
});
64
-
65
61
```
62
+
66
63
3 . ` cd testing-for-charity/my-react-app `
67
64
4 . ` npm run test:visual `
68
- 5 . View your results in Screener.io
65
+ 5 . View your results in Screener.io
69
66
70
67
[ Let's fill out the Test coverage] ( ./TEST-COVERAGE.md )
71
68
@@ -78,12 +75,12 @@ describe('My app', () => {
78
75
We're going to update the React image to something better. What tests should break?
79
76
80
77
1 . Drag n drop a new image to the ` testing-for-charity/my-react-app/src `
81
- 2 . In ` App.js ` , Fix the path of the image to match your new image name ` import logo from './mia.jpg'; `
82
- 2 . Save all files
83
- 3 . Stop the React app ` ctrl + C ` in the server terminal
84
- 4 . Restart the app with ` npm start `
85
- 5 . Rerun the visual tests with ` npm run test:visual `
86
- 6 . Analyze the results in Screener dashboard
78
+ 2 . In ` App.js ` , Fix the path of the image to match your new image name ` import logo from './mia.jpg'; `
79
+ 3 . Save all files
80
+ 4 . Stop the React app ` ctrl + C ` in the server terminal
81
+ 5 . Restart the app with ` npm start `
82
+ 6 . Rerun the visual tests with ` npm run test:visual `
83
+ 7 . Analyze the results in Screener dashboard
87
84
88
85
## Add a step to CI
89
86
0 commit comments