33Test plotly.js with Plotly's image testing docker container.
44
55Requirements:
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 ]
98
109### Step 0: Start the docker machine (Mac and Windows users only)
1110
@@ -21,7 +20,7 @@ If this is your first time, you'll need to create the machine instead:
2120docker-machine create --driver virtualbox default
2221```
2322
24- Set up the docker environment for ` docker-compose ` :
23+ Set up the docker environment:
2524
2625``` bash
2726eval $( docker-machine env default)
@@ -30,25 +29,33 @@ eval $(docker-machine env default)
3029the above evaluates the output of ` docker-machine env default ` .
3130
3231
33- ### Step 1: Run the testing container
32+ ### Step 1: Setup the testing container
3433
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
3635
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
3844
3945``` bash
40- docker-compose up -d
46+ npm run docker -- run
4147```
4248
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+
4652
4753### Step 2: Run the image tests
4854
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.
5259
5360** IMPORTANT:** the image tests scripts do ** not** bundle the source files before
5461running 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
6067[ ` test/image/mocks ` ] [ mocks ] ), generate test png images (saved in
6168` build/test_images/ ` - which is git-ignored) and compare them pixel-by-pixel to
6269their 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 ] .
6571
6672To run the image comparison tests, in your ` plotly.js ` directory:
6773
@@ -73,7 +79,7 @@ which runs all image comparison tests in batch. If some tests fail, compare thei
7379by booting up the test image viewer using ` npm run start-image_viewer ` .
7480
7581As 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
7783[ ` test/image/mocks ` ] [ mocks ] .
7884For example,
7985
@@ -132,9 +138,11 @@ npm run baseline -- <glob-of-mocks-to-update>
132138Once done testing, inside your ` plotly.js ` directory, run
133139
134140``` bash
135- docker-compose stop
141+ npm run docker -- stop
136142```
137143
144+ which calls [ ` docker-stop ` ] [ docker-stop ] with the correct arguments.
145+
138146Mac and Windows user should also kill their docker-machine (named ` default ` ) once done testing:
139147
140148``` bash
@@ -174,9 +182,11 @@ whereas `docker ps` lists only the started containers.
174182Inside your ` plotly.js ` directory, run
175183
176184``` bash
177- docker-compose rm -f
185+ npm run docker -- remove
178186```
179187
188+ which calls [ ` docker-rm ` ] [ docker-rm ] with the correct arguments.
189+
180190##### Remove your docker machine
181191
182192If named ` default ` :
@@ -189,3 +199,13 @@ For more comprehensive information about docker, please refer to the [docker doc
189199
190200[ mocks ] : https://github.com/plotly/plotly.js/tree/master/test/image/mocks
191201[ 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