@@ -26,12 +26,21 @@ else runSingle(userFileName);
26
26
function runAll ( ) {
27
27
test ( 'testing mocks' , function ( t ) {
28
28
29
- console . error ( '### beginning pixel comparison tests ###' ) ;
30
29
var files = fs . readdirSync ( constants . pathToTestImageMocks ) ;
31
30
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 ) ;
35
44
36
45
for ( var i = 0 ; i < files . length ; i ++ ) {
37
46
testMock ( files [ i ] , t ) ;
@@ -54,6 +63,9 @@ function testMock (fileName, t) {
54
63
// TODO fix race condition in gl2d image generation
55
64
if ( fileName . indexOf ( 'gl2d_' ) !== - 1 ) return ;
56
65
66
+ // TODO fix run-to-run randomness
67
+ if ( fileName === 'gl3d_bunny-hull.json' ) return ;
68
+
57
69
var figure = require ( path . join ( constants . pathToTestImageMocks , fileName ) ) ;
58
70
var bodyMock = {
59
71
figure : figure ,
@@ -66,7 +78,6 @@ function testMock (fileName, t) {
66
78
var diffPath = path . join ( constants . pathToTestImagesDiff , 'diff-' + imageFileName ) ;
67
79
var savedImageStream = fs . createWriteStream ( savedImagePath ) ;
68
80
var options = getOptions ( bodyMock , 'http://localhost:9010/' ) ;
69
- var statusCode ;
70
81
71
82
function checkImage ( ) {
72
83
var options = {
@@ -75,17 +86,12 @@ function testMock (fileName, t) {
75
86
tolerance : 0.0
76
87
} ;
77
88
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
+ ) ;
89
95
}
90
96
91
97
function onEqualityCheck ( err , isEqual ) {
@@ -95,16 +101,12 @@ function testMock (fileName, t) {
95
101
}
96
102
if ( isEqual ) {
97
103
fs . unlinkSync ( diffPath ) ;
98
- console . error ( imageFileName + ' is pixel perfect' ) ;
99
104
}
100
105
101
- t . ok ( isEqual , savedImagePath + ' should be pixel perfect' ) ;
106
+ t . ok ( isEqual , imageFileName + ' should be pixel perfect' ) ;
102
107
}
103
108
104
109
request ( options )
105
- . on ( 'response' , function ( response ) {
106
- statusCode = response . statusCode ;
107
- } )
108
110
. pipe ( savedImageStream )
109
111
. on ( 'close' , checkImage ) ;
110
112
}
0 commit comments