@@ -26,12 +26,21 @@ else runSingle(userFileName);
2626function runAll ( ) {
2727 test ( 'testing mocks' , function ( t ) {
2828
29- console . error ( '### beginning pixel comparison tests ###' ) ;
3029 var files = fs . readdirSync ( constants . pathToTestImageMocks ) ;
3130
32- // -1 for font-wishlist and
33- // -38 for the gl2d mocks
34- t . plan ( files . length - 39 ) ;
31+ /*
32+ * Some test cases exhibit run-to-run randomness;
33+ * skip over these few test cases for now.
34+ *
35+ * More info:
36+ * https://github.com/plotly/plotly.js/issues/62
37+ *
38+ * 40 test cases are removed:
39+ * - font-wishlist (1 test case)
40+ * - all gl2d (38)
41+ * - gl2d_bunny-hull (1)
42+ */
43+ t . plan ( files . length - 40 ) ;
3544
3645 for ( var i = 0 ; i < files . length ; i ++ ) {
3746 testMock ( files [ i ] , t ) ;
@@ -54,6 +63,9 @@ function testMock (fileName, t) {
5463 // TODO fix race condition in gl2d image generation
5564 if ( fileName . indexOf ( 'gl2d_' ) !== - 1 ) return ;
5665
66+ // TODO fix run-to-run randomness
67+ if ( fileName === 'gl3d_bunny-hull.json' ) return ;
68+
5769 var figure = require ( path . join ( constants . pathToTestImageMocks , fileName ) ) ;
5870 var bodyMock = {
5971 figure : figure ,
@@ -66,7 +78,6 @@ function testMock (fileName, t) {
6678 var diffPath = path . join ( constants . pathToTestImagesDiff , 'diff-' + imageFileName ) ;
6779 var savedImageStream = fs . createWriteStream ( savedImagePath ) ;
6880 var options = getOptions ( bodyMock , 'http://localhost:9010/' ) ;
69- var statusCode ;
7081
7182 function checkImage ( ) {
7283 var options = {
@@ -75,17 +86,12 @@ function testMock (fileName, t) {
7586 tolerance : 0.0
7687 } ;
7788
78- if ( statusCode === 485 ) {
79- console . error ( imageFileName , '- skip' ) ;
80- }
81- else {
82- gm . compare (
83- savedImagePath ,
84- path . join ( constants . pathToTestImageBaselines , imageFileName ) ,
85- options ,
86- onEqualityCheck
87- ) ;
88- }
89+ gm . compare (
90+ savedImagePath ,
91+ path . join ( constants . pathToTestImageBaselines , imageFileName ) ,
92+ options ,
93+ onEqualityCheck
94+ ) ;
8995 }
9096
9197 function onEqualityCheck ( err , isEqual ) {
@@ -95,16 +101,12 @@ function testMock (fileName, t) {
95101 }
96102 if ( isEqual ) {
97103 fs . unlinkSync ( diffPath ) ;
98- console . error ( imageFileName + ' is pixel perfect' ) ;
99104 }
100105
101- t . ok ( isEqual , savedImagePath + ' should be pixel perfect' ) ;
106+ t . ok ( isEqual , imageFileName + ' should be pixel perfect' ) ;
102107 }
103108
104109 request ( options )
105- . on ( 'response' , function ( response ) {
106- statusCode = response . statusCode ;
107- } )
108110 . pipe ( savedImageStream )
109111 . on ( 'close' , checkImage ) ;
110112}
0 commit comments