test: update fetch fixtures only when requested

avoids automagic http requests in tests
This commit is contained in:
WebStreamr 2025-05-25 19:12:36 +02:00
parent f3beb72f17
commit faa6eb6ed7
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

View file

@ -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": {

View file

@ -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({