fix: ESM compatibility - avoid direct Response object mutation #2708
Annotations
30 errors
|
tests/extended.test.ts > extended > 'full-swagger-scheme':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'full-swagger-scheme' 1` mismatched
- Expected
+ Received
@@ -38343,33 +38343,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
- } as HttpResponse<T, E>;
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'explode-param-3':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'explode-param-3' 1` mismatched
- Expected
+ Received
@@ -302,33 +302,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'enum-type-mismatch':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'enum-type-mismatch' 1` mismatched
- Expected
+ Received
@@ -255,33 +255,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'components-responses':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'components-responses' 1` mismatched
- Expected
+ Received
@@ -254,33 +254,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'callback-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'callback-example' 1` mismatched
- Expected
+ Received
@@ -274,33 +274,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'api-with-examples':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'api-with-examples' 1` mismatched
- Expected
+ Received
@@ -252,33 +252,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'anyof-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'anyof-example' 1` mismatched
- Expected
+ Received
@@ -266,33 +266,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'allof-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'allof-example' 1` mismatched
- Expected
+ Received
@@ -272,33 +272,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'additional-properties2':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'additional-properties2' 1` mismatched
- Expected
+ Received
@@ -236,33 +236,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'additional-properties':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'additional-properties' 1` mismatched
- Expected
+ Received
@@ -239,33 +239,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'full-swagger-scheme':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'full-swagger-scheme' 1` mismatched
- Expected
+ Received
@@ -38343,33 +38343,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
- } as HttpResponse<T, E>;
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'explode-param-3':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'explode-param-3' 1` mismatched
- Expected
+ Received
@@ -302,33 +302,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'enum-type-mismatch':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'enum-type-mismatch' 1` mismatched
- Expected
+ Received
@@ -255,33 +255,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'components-responses':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'components-responses' 1` mismatched
- Expected
+ Received
@@ -254,33 +254,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'callback-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'callback-example' 1` mismatched
- Expected
+ Received
@@ -274,33 +274,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'api-with-examples':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'api-with-examples' 1` mismatched
- Expected
+ Received
@@ -252,33 +252,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'anyof-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'anyof-example' 1` mismatched
- Expected
+ Received
@@ -266,33 +266,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'allof-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'allof-example' 1` mismatched
- Expected
+ Received
@@ -272,33 +272,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'additional-properties2':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'additional-properties2' 1` mismatched
- Expected
+ Received
@@ -236,33 +236,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'additional-properties':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'additional-properties' 1` mismatched
- Expected
+ Received
@@ -239,33 +239,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'full-swagger-scheme':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'full-swagger-scheme' 1` mismatched
- Expected
+ Received
@@ -38343,33 +38343,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
- } as HttpResponse<T, E>;
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'explode-param-3':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'explode-param-3' 1` mismatched
- Expected
+ Received
@@ -302,33 +302,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'enum-type-mismatch':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'enum-type-mismatch' 1` mismatched
- Expected
+ Received
@@ -255,33 +255,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'components-responses':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'components-responses' 1` mismatched
- Expected
+ Received
@@ -254,33 +254,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'callback-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'callback-example' 1` mismatched
- Expected
+ Received
@@ -274,33 +274,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'api-with-examples':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'api-with-examples' 1` mismatched
- Expected
+ Received
@@ -252,33 +252,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'anyof-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'anyof-example' 1` mismatched
- Expected
+ Received
@@ -266,33 +266,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'allof-example':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'allof-example' 1` mismatched
- Expected
+ Received
@@ -272,33 +272,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'additional-properties2':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'additional-properties2' 1` mismatched
- Expected
+ Received
@@ -236,33 +236,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|
|
tests/extended.test.ts > extended > 'additional-properties':
tests/extended.test.ts#L43
Error: Snapshot `extended > 'additional-properties' 1` mismatched
- Expected
+ Received
@@ -239,33 +239,52 @@
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
- // Create a wrapper object that doesn't mutate the Response
+ // Create a Proxy that wraps the Response without mutating it
// This ensures compatibility with ESM environments where Response is read-only
- const r = {
- data: null as unknown as T,
- error: null as unknown as E,
- // Delegate Response properties
- ok: response.ok,
- status: response.status,
- statusText: response.statusText,
+ // while maintaining all Response properties and methods as live/dynamic values
+ const r = new Proxy(response, {
+ get(target, prop) {
+ // Custom properties for our API wrapper
+ if (prop === "data") {
+ return target._data !== undefined
+ ? target._data
+ : (null as unknown as T);
+ }
+ if (prop === "error") {
+ return target._error !== undefined
+ ? target._error
+ : (null as unknown as E);
+ }
+
+ // Delegate everything else to the actual Response object
+ const value = target[prop];
+
+ // Bind methods to the original response to maintain correct 'this' context
- headers: response.headers,
- url: response.url,
- redirected: response.redirected,
- type: response.type,
- body: response.body,
- bodyUsed: response.bodyUsed,
+ if (typeof value === "function") {
+ return value.bind(target);
+ }
+
+ return value;
+ },
+ set(target, prop, value) {
- // Delegate Response methods
- arrayBuffer: () => response.arrayBuffer(),
- blob: () => response.blob(),
- clone: () => response.clone(),
- formData: () => response.formData(),
- json: () => response.json(),
- text: () => response.text(),
+ // Allow setting data and error properties
+ if (prop === "data") {
+ target._data = value;
+ return true;
+ }
+ if (prop === "error") {
+ target._error = value;
+ return true;
+ }
+
+ // Prevent mutation of Response properties (ESM safety)
+ return false;
+ },
- } as HttpResponse<T, E>;
+ }) as HttpResponse<T, E>;
const responseToParse = responseFormat ? response.clone() : response;
const data = !responseFormat
? r
: await responseToParse[responseFormat]()
❯ tests/extended.test.ts:43:21
|