Skip to content

Commit

Permalink
fix(tests): set mocked state
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Jun 29, 2022
1 parent 8e38168 commit 18356f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/app/metrics/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down
1 change: 1 addition & 0 deletions tests/mocks/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down

0 comments on commit 18356f3

Please sign in to comment.