3
3
Test plotly.js with Plotly's image testing docker container.
4
4
5
5
Requirements:
6
- - ` docker ` | [ installation guidelines] ( http://docs.docker.com/engine/installation/ )
7
- - ` docker-machine ` (for Mac and Windows users only) | [ installation guidelines] ( https://docs.docker.com/machine/install-machine/ )
8
- - ` docker-compose ` | [ installation guidelines] ( https://docs.docker.com/compose/install/ )
6
+ - ` docker ` | [ installation guidelines] [ docker-install ]
7
+ - ` docker-machine ` (for Mac and Windows users only) | [ installation guidelines] [ docker-machine-install ]
9
8
10
9
### Step 0: Start the docker machine (Mac and Windows users only)
11
10
@@ -21,7 +20,7 @@ If this is your first time, you'll need to create the machine instead:
21
20
docker-machine create --driver virtualbox default
22
21
```
23
22
24
- Set up the docker environment for ` docker-compose ` :
23
+ Set up the docker environment:
25
24
26
25
``` bash
27
26
eval $( docker-machine env default)
@@ -30,25 +29,33 @@ eval $(docker-machine env default)
30
29
the above evaluates the output of ` docker-machine env default ` .
31
30
32
31
33
- ### Step 1: Run the testing container
32
+ ### Step 1: Setup the testing container
34
33
35
- We use ` docker-compose ` to ease the creation/stopping/deletion of the testing docker container.
34
+ After ` cd ` into your ` plotly.js ` directory, pull the latest docker image with
36
35
37
- Inside your ` plotly.js ` directory, run
36
+ ``` bash
37
+ npm run docker -- pull
38
+ ```
39
+
40
+ which calls [ ` docker-pull ` ] [ docker-pull ] with the correct arguments grabbing the
41
+ latest docker image as listed on [ hub.docker.com] [ docker-hub ] .
42
+
43
+ Run the container with
38
44
39
45
``` bash
40
- docker-compose up -d
46
+ npm run docker -- run
41
47
```
42
48
43
- In the ` docker-compose.yml ` file, ` latest ` is the latest Plotly Image-Server docker container version
44
- as listed on [ hub.docker.com ] ( https://hub.docker.com/r/plotly/testbed/tags/ ) and
45
- ` imagetest ` is the name of the docker container. The ` -d ` flag tells docker to start the containers in the background and leave them running.
49
+ which calls [ ` docker-run ` ] [ docker-run ] or [ ` docker-start ` ] [ docker-start ] with
50
+ the correct arguments.
51
+
46
52
47
53
### Step 2: Run the image tests
48
54
49
- The image testing docker container allows plotly.js developers to ([ A] ( #a-run-image-comparison-tests ) ) run image
50
- comparison tests, ([ B] ( #b-run-image-export-tests ) ) run image export tests and ([ C] ( #c-generate-or-update-existing-baseline-image ) ) generate baseline
51
- images.
55
+ The image testing docker container allows plotly.js developers to
56
+ ([ A] ( #a-run-image-comparison-tests ) ) run image comparison tests,
57
+ ([ B] ( #b-run-image-export-tests ) ) run image export tests and
58
+ ([ C] ( #c-generate-or-update-existing-baseline-image ) ) generate baseline images.
52
59
53
60
** IMPORTANT:** the image tests scripts do ** not** bundle the source files before
54
61
running the image tests. We recommend running ` npm run watch ` or ` npm start ` in
@@ -60,8 +67,7 @@ Image comparison tests take in plotly.js mock json files (found in
60
67
[ ` test/image/mocks ` ] [ mocks ] ), generate test png images (saved in
61
68
` build/test_images/ ` - which is git-ignored) and compare them pixel-by-pixel to
62
69
their corresponding baseline images (found in
63
- [ ` test/image/baselines ` ] [ baselines ] ) using
64
- [ ` GraphicsMagick ` ] ( https://github.com/aheckmann/gm ) .
70
+ [ ` test/image/baselines ` ] [ baselines ] ) using [ ` GraphicsMagick ` ] [ gm ] .
65
71
66
72
To run the image comparison tests, in your ` plotly.js ` directory:
67
73
@@ -73,7 +79,7 @@ which runs all image comparison tests in batch. If some tests fail, compare thei
73
79
by booting up the test image viewer using ` npm run start-image_viewer ` .
74
80
75
81
As an alternative to running all image comparison tests at once, you can provide
76
- a [ glob] ( https://github.com/isaacs/node- glob) as argument to target one or multiple test mocks found in
82
+ a [ glob] [ glob ] as argument to target one or multiple test mocks found in
77
83
[ ` test/image/mocks ` ] [ mocks ] .
78
84
For example,
79
85
@@ -132,9 +138,11 @@ npm run baseline -- <glob-of-mocks-to-update>
132
138
Once done testing, inside your ` plotly.js ` directory, run
133
139
134
140
``` bash
135
- docker-compose stop
141
+ npm run docker -- stop
136
142
```
137
143
144
+ which calls [ ` docker-stop ` ] [ docker-stop ] with the correct arguments.
145
+
138
146
Mac and Windows user should also kill their docker-machine (named ` default ` ) once done testing:
139
147
140
148
``` bash
@@ -174,9 +182,11 @@ whereas `docker ps` lists only the started containers.
174
182
Inside your ` plotly.js ` directory, run
175
183
176
184
``` bash
177
- docker-compose rm -f
185
+ npm run docker -- remove
178
186
```
179
187
188
+ which calls [ ` docker-rm ` ] [ docker-rm ] with the correct arguments.
189
+
180
190
##### Remove your docker machine
181
191
182
192
If named ` default ` :
@@ -189,3 +199,13 @@ For more comprehensive information about docker, please refer to the [docker doc
189
199
190
200
[ mocks ] : https://github.com/plotly/plotly.js/tree/master/test/image/mocks
191
201
[ baselines ] : https://github.com/plotly/plotly.js/tree/master/test/image/baselines
202
+ [ docker-install ] : http://docs.docker.com/engine/installation/
203
+ [ docker-machine-install ] : https://docs.docker.com/machine/install-machine/
204
+ [ docker-hub ] : https://hub.docker.com/r/plotly/testbed/tags/
205
+ [ docker-pull ] : https://docs.docker.com/engine/reference/commandline/pull/
206
+ [ docker-run ] : https://docs.docker.com/engine/reference/commandline/run/
207
+ [ docker-start ] : https://docs.docker.com/engine/reference/commandline/start/
208
+ [ docker-stop ] : https://docs.docker.com/engine/reference/commandline/stop/
209
+ [ docker-rm ] : https://docs.docker.com/engine/reference/commandline/rm/
210
+ [ gm ] : https://github.com/aheckmann/gm
211
+ [ glob ] : https://github.com/isaacs/node-glob
0 commit comments