fix(tests): set mocked state

This commit is contained in:
lowlighter
2022-06-29 00:05:59 -04:00
parent 8e38168815
commit 18356f3d4f
2 changed files with 2 additions and 1 deletions

View File

@@ -332,7 +332,7 @@ export async function imgb64(image, {width, height, fallback = true} = {}) {
//Load image //Load image
try { 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 //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) image = (await axios.get(image)).then(response => response.request.responseURL).catch(() => null)
console.debug(`metrics/svg/imgb64 > redirected image link to ${image}`) console.debug(`metrics/svg/imgb64 > redirected image link to ${image}`)
} }

View File

@@ -8,6 +8,7 @@ import urls from "url"
//Mocked state //Mocked state
let mocked = false let mocked = false
process.env.METRICS_MOCKED = true
//Mocking //Mocking
export default async function({graphql, rest}) { export default async function({graphql, rest}) {