Skip to content

Commit 631bae8

Browse files
committed
Stabilize unit test in Chrome. Test image wasn't always loaded in time
1 parent c155c33 commit 631bae8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/specs/Svg2ImageSpec.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@ describe("Svg to Image", function () {
5959
'</svg>'
6060
);
6161

62-
svg2image.renderSvg(twoColorSvg, null).then(function (image) {
63-
// This fails in Chrome & Safari, possibly due to a bug with same origin policy stuff
64-
try {
65-
expect(image).toImageDiffEqual(referenceImg);
66-
} catch (err) {
67-
expect(err.message).toBeNull();
68-
}
62+
referenceImg.onload = function () {
63+
svg2image.renderSvg(twoColorSvg, null).then(function (image) {
64+
// This fails in Safari, possibly due to a bug with same origin policy stuff
65+
try {
66+
expect(image).toImageDiffEqual(referenceImg);
67+
} catch (err) {
68+
expect(err).toBeNull();
69+
}
6970

70-
done();
71-
});
71+
done();
72+
});
73+
};
7274
});
7375

7476
it("should return an error when the SVG cannot be rendered", function (done) {

0 commit comments

Comments
 (0)