Use NOCK_ENV=replay by default

Replaying HTTP requests makes the tests faster and aligns them with CI.
This commit is contained in:
Thomas Scholtes 2025-02-11 18:36:25 +01:00
parent d26a552daa
commit cdae6e514d
No known key found for this signature in database
GPG Key ID: 7E113D26B1FDDDED
3 changed files with 2 additions and 4 deletions

View File

@ -89,5 +89,3 @@ jobs:
- run: corepack yarn build # We need the stubs to run the tests
- run: corepack yarn test
env:
NOCK_ENV: replay

View File

@ -223,7 +223,7 @@ switch (process.env.AUTH_TYPE) {
default: throw new Error(`Invalid AUTH_TYPE in env`, {cause: process.env.AUTH_TYPE});
}
if (process.env.NOCK_ENV === `replay`) {
if (process.env.NOCK_ENV !== `record`) {
const originalFetch = globalThis.fetch;
globalThis.fetch = function fetch(i) {
if (!`${i}`.startsWith(

View File

@ -69,7 +69,7 @@ if (process.env.NOCK_ENV === `record`) {
headers: minimalHeaders,
});
};
} else if (process.env.NOCK_ENV === `replay`) {
} else {
const getNockStatement = db.prepare(`SELECT body, json(headers) as headers, status FROM nocks WHERE hash = ?`);
globalThis.fetch = async (input, init) => {