Skip to content

Commit

Permalink
Bump react-related libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Sep 22, 2024
1 parent 6373f52 commit 3b66391
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 261 deletions.
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@
"react-native"
],
"allowedVersions": {
"react": "17",
"react-dom": "17",
"react-is": "17",
"styled-components": "5"
}
},
"overrides": {
"@types/react": "^17.0.39",
"graphql": "^16.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"styled-components": "^5.2.3",
"wonka": "^6.3.2"
}
Expand Down
15 changes: 7 additions & 8 deletions packages/react-urql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@
},
"devDependencies": {
"@cypress/react": "^8.0.2",
"@cypress/vite-dev-server": "^5.0.4",
"@testing-library/react": "^11.1.1",
"@testing-library/react-hooks": "^5.1.2",
"@cypress/vite-dev-server": "^5.2.0",
"@testing-library/react": "^16.0.1",
"@types/react": "^17.0.4",
"@types/react-test-renderer": "^17.0.1",
"@urql/core": "workspace:*",
"cypress": "^13.14.0",
"graphql": "^16.6.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-is": "^17.0.1",
"react-ssr-prepass": "^1.1.2",
"react-test-renderer": "^17.0.1"
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-is": "^18.3.1",
"react-ssr-prepass": "^1.5.0",
"react-test-renderer": "^18.3.1"
},
"peerDependencies": {
"@urql/core": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-urql/src/components/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vi.mock('../context', async () => {
const mock = {
executeQuery: vi.fn(() =>
pipe(
interval(200),
interval(150),
map((i: number) => ({ data: i, error: i + 1 }))
)
),
Expand Down
62 changes: 27 additions & 35 deletions packages/react-urql/src/hooks/useQuery.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook, act } from '@testing-library/react-hooks';
import { renderHook, act } from '@testing-library/react';
import { interval, map, pipe } from 'wonka';
import { RequestPolicy } from '@urql/core';
import { vi, expect, it, beforeEach, describe, beforeAll, Mock } from 'vitest';
Expand Down Expand Up @@ -87,22 +87,18 @@ describe('useQuery', () => {
});

it('should execute the subscription', async () => {
const { waitForNextUpdate } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);
renderHook(({ query, variables }) => useQuery({ query, variables }), {

Check failure on line 90 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should execute the subscription

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:90:5
initialProps: { query: mockQuery, variables: mockVariables },
});

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);
});

it('should pass query and variables to executeQuery', async () => {
const { waitForNextUpdate } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);
renderHook(({ query, variables }) => useQuery({ query, variables }), {

Check failure on line 98 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should pass query and variables to executeQuery

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:98:5
initialProps: { query: mockQuery, variables: mockVariables },
});

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);
expect(client.executeQuery).toBeCalledWith(
{
Expand All @@ -117,12 +113,12 @@ describe('useQuery', () => {
});

it('should return data from executeQuery', async () => {
const { result, waitForNextUpdate } = renderHook(
const { result } = renderHook(

Check failure on line 116 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should return data from executeQuery

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:116:24
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);

await waitForNextUpdate();
await new Promise(res => setTimeout(res, 30));
const [state] = result.current;
expect(state).toEqual({
fetching: false,
Expand All @@ -134,14 +130,13 @@ describe('useQuery', () => {
});

it('should update if a new query is received', async () => {
const { rerender, waitForNextUpdate } = renderHook<
{ query: string; variables?: object },
{}
const { rerender } = renderHook<

Check failure on line 133 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should update if a new query is received

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:133:26
any,
{ query: string; variables: { id?: number } }
>(({ query, variables }) => useQuery({ query, variables }), {
initialProps: { query: mockQuery, variables: mockVariables },
});

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

const newQuery = `
Expand All @@ -151,7 +146,7 @@ describe('useQuery', () => {
}
`;

rerender({ query: newQuery });
rerender({ query: newQuery, variables: {} });
expect(client.executeQuery).toBeCalledTimes(2);
expect(client.executeQuery).toHaveBeenNthCalledWith(
2,
Expand All @@ -167,14 +162,13 @@ describe('useQuery', () => {
});

it('should update if new variables are received', async () => {
const { rerender, waitForNextUpdate } = renderHook<
{ query: string; variables: object },
{}
>(({ query, variables }) => useQuery({ query, variables }), {
initialProps: { query: mockQuery, variables: mockVariables },
});
const { rerender } = renderHook(

Check failure on line 165 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should update if new variables are received

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:165:26
({ query, variables }) => useQuery({ query, variables }),
{
initialProps: { query: mockQuery, variables: mockVariables },
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

const newVariables = {
Expand All @@ -197,22 +191,21 @@ describe('useQuery', () => {
});

it('should not update if query and variables are unchanged', async () => {
const { rerender, waitForNextUpdate } = renderHook(
const { rerender } = renderHook(

Check failure on line 194 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should not update if query and variables are unchanged

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:194:26
({ query, variables }) => useQuery({ query, variables }),
{
initialProps: { query: mockQuery, variables: mockVariables },
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

rerender({ query: mockQuery, variables: mockVariables });
expect(client.executeQuery).toBeCalledTimes(1);
});

it('should update if a new requestPolicy is provided', async () => {
const { rerender, waitForNextUpdate } = renderHook(
const { rerender } = renderHook(

Check failure on line 208 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should update if a new requestPolicy is provided

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:208:26
({ query, variables, requestPolicy }) =>
useQuery({ query, variables, requestPolicy }),
{
Expand All @@ -224,7 +217,6 @@ describe('useQuery', () => {
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);
expect(client.executeQuery).toHaveBeenNthCalledWith(
1,
Expand Down Expand Up @@ -258,17 +250,15 @@ describe('useQuery', () => {
});

it('should provide an executeQuery function to be imperatively executed', async () => {
const { result, waitForNextUpdate } = renderHook(
const { result } = renderHook(

Check failure on line 253 in packages/react-urql/src/hooks/useQuery.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

packages/react-urql/src/hooks/useQuery.spec.ts > useQuery > should provide an executeQuery function to be imperatively executed

ReferenceError: document is not defined ❯ render node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:239:5 ❯ Proxy.renderHook node_modules/.pnpm/@testing-library[email protected]_@[email protected]_@[email protected]_@types+reac_2z556pqkgdckpc6j3ggdnekisy/node_modules/@testing-library/react/dist/pure.js:318:7 ❯ packages/react-urql/src/hooks/useQuery.spec.ts:253:24
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

const [, executeQuery] = result.current;
act(() => executeQuery());
await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(2);
});

Expand All @@ -288,8 +278,11 @@ describe('useQuery', () => {
});

it('should pause executing the query if pause updates to true', async () => {
const { rerender, waitForNextUpdate } = renderHook(
({ query, variables, pause }) => useQuery({ query, variables, pause }),
const { rerender } = renderHook(
props => {
const { query, variables, pause } = props;
return useQuery({ query, variables, pause });
},
{
initialProps: {
query: mockQuery,
Expand All @@ -299,7 +292,6 @@ describe('useQuery', () => {
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

rerender({ query: mockQuery, variables: mockVariables, pause: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/react-urql/src/hooks/useRequest.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { gql } from '@urql/core';
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { it, expect } from 'vitest';
import { useRequest } from './useRequest';

Expand Down
6 changes: 5 additions & 1 deletion packages/react-urql/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { mergeConfig } from 'vitest/config';
import baseConfig from '../../vitest.config';

export default mergeConfig(baseConfig, {});
export default mergeConfig(baseConfig, {
test: {
environment: 'jsdom',
},
});
Loading

0 comments on commit 3b66391

Please sign in to comment.