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
-[Setting up a UI Library](#setting-up-a-ui-library)
8
-
-[Creating tests](#creating-tests)
9
-
-[Running Tests](#running-tests)
10
-
-[Viewing Test Results](#viewing-test-results)
11
-
-[Reference and Screen](#reference-and-screen)
12
-
13
-
</nav>
5
+
## What is the Screenshot Testing
6
+
Screenshot test is visual test that takes a screenshot, then compares it to a reference screenshot file saved. When ui changes, one of the major considerations is whether visual changes exist. Some changes may be easy to check, but some changes are hard to check due to very small change. With Screenshot test, very small changes can easily check due to compare pixel-by-pixel. Additionally, Screenshot testing is the most reliable test for static images.
14
7
15
8
## Prerequisites
16
-
Created a enact project using the enact cli.
17
-
18
-
## Setting up a UI Library
19
-
1. Add @enact/ui-test-utils as a devDependency: npm i --save-dev @enact/ui-test-utils.
20
-
21
-
2. Create the tests/screenshot folder structure within the UI library.
22
-
23
-
3. Add apps and specs folders to tests/screenshot.
24
-
25
-
4. Add local WebDriver configuration files within tests/screenshot:
5. Add npm scripts for each of the above configuration files. There are likely other scripts already defined so these will be added to the existing scripts.
Clone sandstone from GitHub, install dependencies and connect the modules using Lerna:
10
+
11
+
```shell
12
+
# clone the repo!
13
+
git clone git@github.com:enactjs/sandstone.git
14
+
# move in
15
+
cd sandstone
16
+
# we're using git flow so develop is our working branch
17
+
git checkout develop
18
+
# install lerna
19
+
npm install
20
+
# link dependencies
21
+
enact link
48
22
```
49
23
50
24
## Creating tests
@@ -54,9 +28,9 @@ Within the UI Library, create an app for testing in `./tests/screenshot/apps` an
54
28
+ test
55
29
+ screenshot
56
30
+ apps
57
-
+ component
58
-
+ testComponent
59
-
testComponent.js <-- create app here
31
+
+ component
32
+
+ testComponent
33
+
testComponent.js <-- create app here
60
34
+ specs
61
35
testComponent-specs.js <-- create spec file here
62
36
@@ -103,13 +77,10 @@ For a single-run, execute `npm run test-ss`.
103
77
`npm run test-ss -- --component <name-of-component> --skip-build`
104
78
105
79
## Viewing Test Results
106
-
* After a test runs, if new screenshots are generated, a page is created with links to open each of the images. To open this file (on a Mac):
107
-
`open tests/screenshot/dist/newFiles.html`
108
-
* If there are test failures, a failure log is created that contains links to the sets of images. To open this file (on a Mac):
109
-
`open tests/screenshot/dist/failedTests.html`
80
+
* After a test runs, if new screenshots are generated, a page is created with links to open each of the images. To open this file (on a Mac): `open tests/screenshot/dist/newFiles.html`
81
+
* If there are test failures, a failure log is created that contains links to the sets of images. To open this file (on a Mac): `open tests/screenshot/dist/failedTests.html`
110
82
Images can be navigated using the keyboard arrow keys. Click on an image to zoom in. Click out of the image to zoom out.
111
-
* In the output, the test case button opens the sample app with the parameters that produced the output. This requires that a server be running on port 5000. If you have globally installed the serve command with npm install -g serve you can start the server like this:
112
-
`serve tests/screenshot/dist`
83
+
* In the output, the test case button opens the sample app with the parameters that produced the output. This requires that a server be running on port 5000. If you have globally installed the serve command with npm install -g serve you can start the server like this: `serve tests/screenshot/dist`
113
84
114
85
## Reference and Screen
115
86
Screenshot testing is a test that compares and assures two different outputs. For the first test without any criteria, all results are saved in the `tests/screenshot/dist/reference` and they become criteria for later tests. In Second run, all results are saved in the `tests/screenshot/dist/screen` and compares screen with reference.
5. Add npm scripts for each of the above configuration files. There are likely other scripts already defined so these will be added to the existing scripts.
0 commit comments