diff --git a/exchanges/execute/src/execute.test.ts b/exchanges/execute/src/execute.test.ts index d9517a16af..c4070fd165 100644 --- a/exchanges/execute/src/execute.test.ts +++ b/exchanges/execute/src/execute.test.ts @@ -196,6 +196,7 @@ describe('on operation', () => { fetchMock.mockResolvedValue({ status: 200, + headers: { get: () => 'application/json' }, text: vi .fn() .mockResolvedValue(JSON.stringify({ data: mockHttpResponseData })), diff --git a/exchanges/graphcache/src/offlineExchange.test.ts b/exchanges/graphcache/src/offlineExchange.test.ts index bc0d9b7482..a6ffebc98c 100644 --- a/exchanges/graphcache/src/offlineExchange.test.ts +++ b/exchanges/graphcache/src/offlineExchange.test.ts @@ -62,7 +62,11 @@ const storage = { describe('storage', () => { it('should read the metadata and dispatch operations on initialization', () => { - const client = createClient({ url: 'http://0.0.0.0' }); + const client = createClient({ + url: 'http://0.0.0.0', + exchanges: [], + }); + const reexecuteOperation = vi .spyOn(client, 'reexecuteOperation') .mockImplementation(() => undefined); @@ -100,7 +104,11 @@ describe('offline', () => { it('should intercept errored mutations', () => { const onlineSpy = vi.spyOn(navigator, 'onLine', 'get'); - const client = createClient({ url: 'http://0.0.0.0' }); + const client = createClient({ + url: 'http://0.0.0.0', + exchanges: [], + }); + const queryOp = client.createRequestOperation('query', { key: 1, query: queryOne, diff --git a/exchanges/multipart-fetch/src/multipartFetchExchange.test.ts b/exchanges/multipart-fetch/src/multipartFetchExchange.test.ts index efd1aea556..f336ce68bf 100644 --- a/exchanges/multipart-fetch/src/multipartFetchExchange.test.ts +++ b/exchanges/multipart-fetch/src/multipartFetchExchange.test.ts @@ -59,6 +59,7 @@ describe('on success', () => { beforeEach(() => { fetch.mockResolvedValue({ status: 200, + headers: { get: () => 'application/json' }, text: vi.fn().mockResolvedValue(response), }); }); @@ -128,6 +129,7 @@ describe('on error', () => { beforeEach(() => { fetch.mockResolvedValue({ status: 400, + headers: { get: () => 'application/json' }, text: vi.fn().mockResolvedValue('{}'), }); }); @@ -163,6 +165,7 @@ describe('on error', () => { it('ignores the error when a result is available', async () => { fetch.mockResolvedValue({ status: 400, + headers: { get: () => 'application/json' }, text: vi.fn().mockResolvedValue(response), }); diff --git a/exchanges/persisted-fetch/src/persistedFetchExchange.test.ts b/exchanges/persisted-fetch/src/persistedFetchExchange.test.ts index 6fe67ff700..76b81e06c3 100644 --- a/exchanges/persisted-fetch/src/persistedFetchExchange.test.ts +++ b/exchanges/persisted-fetch/src/persistedFetchExchange.test.ts @@ -36,6 +36,8 @@ it('accepts successful persisted query responses', async () => { }); fetch.mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expected), }); @@ -63,9 +65,13 @@ it('supports cache-miss persisted query errors', async () => { fetch .mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expectedMiss), }) .mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expectedRetry), }); @@ -94,9 +100,13 @@ it('supports GET exclusively for persisted queries', async () => { fetch .mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expectedMiss), }) .mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expectedRetry), }); @@ -127,12 +137,18 @@ it('supports unsupported persisted query errors', async () => { fetch .mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expectedMiss), }) .mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expectedRetry), }) .mockResolvedValueOnce({ + status: 200, + headers: { get: () => 'application/json' }, text: () => Promise.resolve(expectedRetry), }); diff --git a/packages/svelte-urql/src/mutationStore.test.ts b/packages/svelte-urql/src/mutationStore.test.ts index 525141e6fc..3bd80a6048 100644 --- a/packages/svelte-urql/src/mutationStore.test.ts +++ b/packages/svelte-urql/src/mutationStore.test.ts @@ -6,9 +6,14 @@ import { vi, expect, it, describe } from 'vitest'; import { mutationStore } from './mutationStore'; describe('mutationStore', () => { - const client = createClient({ url: 'https://example.com' }); + const client = createClient({ + url: 'noop', + exchanges: [], + }); + const variables = {}; const context = {}; + const query = 'mutation ($input: Example!) { doExample(input: $input) { id } }'; const store = mutationStore({ @@ -26,14 +31,13 @@ describe('mutationStore', () => { it('fills the store with correct values', () => { expect(get(store).operation.kind).toBe('mutation'); - expect(get(store).operation.context.url).toBe('https://example.com'); + expect(get(store).operation.context.url).toBe('noop'); expect(get(store).operation.variables).toBe(variables); expect(print(get(store).operation.query)).toMatchInlineSnapshot(` "mutation ($input: Example!) { doExample(input: $input) { id - __typename } }" `); diff --git a/packages/svelte-urql/src/queryStore.test.ts b/packages/svelte-urql/src/queryStore.test.ts index 02053e348a..de497d7742 100644 --- a/packages/svelte-urql/src/queryStore.test.ts +++ b/packages/svelte-urql/src/queryStore.test.ts @@ -5,7 +5,11 @@ import { get } from 'svelte/store'; import { queryStore } from './queryStore'; describe('queryStore', () => { - const client = createClient({ url: 'https://example.com' }); + const client = createClient({ + url: 'https://example.com', + exchanges: [], + }); + const variables = {}; const context = {}; const query = '{ test }'; diff --git a/packages/svelte-urql/src/subscriptionStore.test.ts b/packages/svelte-urql/src/subscriptionStore.test.ts index f522e50680..c1929f3c86 100644 --- a/packages/svelte-urql/src/subscriptionStore.test.ts +++ b/packages/svelte-urql/src/subscriptionStore.test.ts @@ -5,7 +5,11 @@ import { vi, expect, it, describe } from 'vitest'; import { subscriptionStore } from './subscriptionStore'; describe('subscriptionStore', () => { - const client = createClient({ url: 'https://example.com' }); + const client = createClient({ + url: 'https://example.com', + exchanges: [], + }); + const variables = {}; const context = {}; const query = `subscription ($input: ExampleInput) { exampleSubscribe(input: $input) { data } }`;