Skip to content

Commit caefe67

Browse files
committed
update image container readme
1 parent 592484d commit caefe67

File tree

1 file changed

+72
-8
lines changed

1 file changed

+72
-8
lines changed

test/image/README.md

+72-8
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,86 @@ as listed on [hub.docker.com](https://hub.docker.com/r/plotly/testbed/tags/) and
4040

4141
### Step 2: Run the image tests
4242

43-
Inside your `plotly.js` directory, run
43+
The image testing docker container allows plotly.js developers to (A) run image
44+
comparison tests, (B) run image export tests and (C) generate baseline
45+
images.
46+
47+
**IMPORTANT:** the image tests scripts do **not** bundle the source files before
48+
running the image tests. We recommend running `npm run watch` or `npm start` in
49+
a separate tab to ensure that the most up-to-date code is used.
50+
51+
##### A: Run image comparison tests
52+
53+
Image comparison tests take in plotly.js mock json files (found in
54+
[`test/image/mocks`][mocks]), generate test png images (saved in
55+
`build/test_images/` - which is git-ignored) and compare them pixel-by-pixel to
56+
their corresponding baseline images (found in
57+
[`test/image/baselines`][baselines]) using
58+
[`GraphicsMagick`](https://github.com/aheckmann/gm).
59+
60+
To run the image comparison tests, in your `plotly.js` directory:
4461

4562
```bash
4663
npm run test-image
4764
```
4865

49-
if some tests fail, compare their outputs using `npm run start-image_viewer`.
66+
which runs all image comparison tests in batch. If some tests fail, compare their outputs
67+
using `npm run start-image_viewer`.
5068

51-
**IMPORTANT:** `npm run test-image` does **not** bundle the source files before running the image tests. We recommend runnnig `npm run watch` or `npm run start-test_dashboard` in a separate tab to ensure that the most up-to-date code is tested.
69+
As an alternative to running all image comparison tests at once, you can provide
70+
a glob as argument to target one or multiple test mocks found in
71+
[`test/image/mocks`][mocks].
72+
For example,
5273

53-
### Step 2b: Make a new or update an existing baseline image
74+
```bash
75+
# Run one test (e.g. the 'contour_nolines' test):
76+
$ npm run test-image -- contour_nolines
5477

55-
Inside your `plotly.js` directory, run
78+
# Run all gl3d image test in batch:
79+
$ npm run test-image -- gl3d_*
80+
```
81+
82+
Developers on weak hardware might encounter batch timeout issue. These are most
83+
common when generated WebGL-based graphs. In this case, running the image
84+
comparison tests in queue (i.e. with no concurrency) is recommended:
5685

5786
```bash
58-
npm run baseline -- mock.json
87+
# Run all gl3d image test in queue:
88+
$ npm run test-image -- gl3d_* --queue
89+
```
90+
91+
##### B: Run image export tests
92+
93+
Image export tests check that image export works for formats other than png.
94+
95+
To run the image export tests, in your `plotly.js` directory:
96+
97+
```bash
98+
npm run test-export
99+
100+
# or
101+
npm run test-export -- <glob>
102+
```
103+
104+
##### C: Generate or update existing baseline image
105+
106+
To generate a new baseline image, add a new mock file in
107+
[`test/image/mocks`][mocks]. Note that mock file needs to be a valid JSON and
108+
have both a "data" and a `"layout"` field. Then, in your plotly.js directory,
109+
run:
110+
111+
```bash
112+
npm run baseline -- <name-of-mock>
113+
```
114+
115+
which generates a baseline png image in [`test/image/baselines`][baselines].
116+
117+
To update existing baseline image(s), run
118+
119+
```bash
120+
npm run basline -- <glob-of-mocks-to-update>
59121
```
60122

61-
where `mock.json` is the name of a `{"data": [], "layout": {}}` json file found in [`test/image/mocks/`](https://github.com/plotly/plotly.js/tree/master/test/image/mocks). The `"data"` and `"layout"` field are passed to `Plotly.plot` to produce an image saved in [`test/image/baslines`](https://github.com/plotly/plotly.js/tree/master/test/image/baselines).
62123

63124
### Step 3: Stop your testing container
64125

@@ -74,7 +135,7 @@ Mac and Windows user should also kill their docker-machine (named `default`) onc
74135
docker-machine kill default
75136
```
76137

77-
### Docker tricks
138+
### Docker tricks
78139

79140
##### SSH into docker container
80141

@@ -145,3 +206,6 @@ docker-machine kill default
145206
```
146207

147208
For more comprehensive information about docker, please refer to the [docker docs](http://docs.docker.com/).
209+
210+
[mocks]: https://github.com/plotly/plotly.js/tree/master/test/image/mocks
211+
[baselines]: https://github.com/plotly/plotly.js/tree/master/test/image/baselines

0 commit comments

Comments
 (0)