From 19fc6a93ec7004f6554bfffef82908512db88f1b Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 28 Apr 2020 10:41:35 +0200 Subject: [PATCH] fix tests --- src/Avatar.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Avatar.js b/src/Avatar.js index 8084f30f33..2e176e569e 100644 --- a/src/Avatar.js +++ b/src/Avatar.js @@ -59,6 +59,10 @@ function urlForColor(color) { canvas.width = size; canvas.height = size; const ctx = canvas.getContext("2d"); + // bail out when using jsdom in unit tests + if (!ctx) { + return ""; + } ctx.fillStyle = color; ctx.fillRect(0, 0, size, size); return canvas.toDataURL();