From faa6eb6ed772cf9ed00cab24aa268137d98ace6c Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Sun, 25 May 2025 19:12:36 +0200 Subject: [PATCH] test: update fetch fixtures only when requested avoids automagic http requests in tests --- package.json | 1 + src/utils/__mocks__/Fetcher.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e87bf8e..e5c1544 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "lint:fix": "eslint --fix", "start": "node dist/index.js", "test": "jest", + "test:update-fixtures": "TEST_UPDATE_FIXTURES=1 npm run test", "ci": "npm run lint && npm run analyse && npm run test" }, "repository": { diff --git a/src/utils/__mocks__/Fetcher.ts b/src/utils/__mocks__/Fetcher.ts index 4fb0545..dd9203a 100644 --- a/src/utils/__mocks__/Fetcher.ts +++ b/src/utils/__mocks__/Fetcher.ts @@ -34,7 +34,12 @@ export class Fetcher { let response; try { - response = await callable(); + if (process.env['TEST_UPDATE_FIXTURES']) { + response = await callable(); + } else { + console.error(`No fixture found at "${path}".`); + process.exit(1); + } } catch (error) { if (error instanceof AxiosError) { const fixtureError = JSON.stringify({