From 18356f3d4fe0690c04cd3775dd22c1528b9a501e Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Wed, 29 Jun 2022 00:05:59 -0400 Subject: [PATCH] fix(tests): set mocked state --- source/app/metrics/utils.mjs | 2 +- tests/mocks/index.mjs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source/app/metrics/utils.mjs b/source/app/metrics/utils.mjs index c55bf9231a9..b6fa9ee022e 100644 --- a/source/app/metrics/utils.mjs +++ b/source/app/metrics/utils.mjs @@ -332,7 +332,7 @@ export async function imgb64(image, {width, height, fallback = true} = {}) { //Load image try { //Fix: redirections are not properly supported by jimp (https://github.com/oliver-moran/jimp/issues/909), seems to occur only when in jest environment - if ((typeof image === "string") && (process.env.JEST_WORKER_ID)) { + if ((typeof image === "string") && ((process.env.JEST_WORKER_ID)||(process.env.METRICS_MOCKED))) { image = (await axios.get(image)).then(response => response.request.responseURL).catch(() => null) console.debug(`metrics/svg/imgb64 > redirected image link to ${image}`) } diff --git a/tests/mocks/index.mjs b/tests/mocks/index.mjs index 724338cf052..780eb48b1ff 100644 --- a/tests/mocks/index.mjs +++ b/tests/mocks/index.mjs @@ -8,6 +8,7 @@ import urls from "url" //Mocked state let mocked = false +process.env.METRICS_MOCKED = true //Mocking export default async function({graphql, rest}) {