Skip to content

Commit 5ebb0d2

Browse files
pkg: Update all non-major dependencies (#3366)
* pkg: Update all non-major dependencies * internal: Test RN using react 19 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathaniel Tucker <[email protected]>
1 parent 9275a45 commit 5ebb0d2

File tree

12 files changed

+212
-222
lines changed

12 files changed

+212
-222
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ jobs:
119119
if [ "<< parameters.react-version >>" == "^17" ]; then
120120
yarn test:ci --maxWorkers=3 --selectProjects ReactDOM --testPathPattern packages/react packages/use-enhanced-reducer packages/img
121121
elif [ "<< parameters.react-version >>" == "^18" ]; then
122+
yarn test:ci --maxWorkers=4 --selectProjects ReactDOM --testPathPattern packages/react packages/use-enhanced-reducer packages/img
123+
else
122124
curl -Os https://uploader.codecov.io/latest/linux/codecov;
123125
chmod +x codecov;
124126
yarn run test:coverage --ci --maxWorkers=3 --coverageReporters=text-lcov > ./lcov.info;
@@ -127,8 +129,6 @@ jobs:
127129
else
128130
./codecov < ./lcov.info || true;
129131
fi
130-
else
131-
yarn test:ci --maxWorkers=4 --selectProjects ReactDOM --testPathPattern packages/react packages/use-enhanced-reducer packages/img
132132
fi
133133
134134
node_matrix:

examples/github-app/package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/github-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"react": "19.0.0",
6464
"react-dom": "19.0.0",
6565
"react-error-boundary": "^5.0.0",
66-
"react-markdown": "9.0.3",
66+
"react-markdown": "9.1.0",
6767
"rehype-highlight": "7.0.2",
6868
"remark-gfm": "^4.0.0",
6969
"remark-remove-comments": "^1.0.1",

examples/nextjs/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@data-client/react": "^0.14.0",
2020
"@data-client/rest": "^0.14.0",
2121
"@number-flow/react": "^0.5.0",
22-
"@types/node": "22.13.4",
22+
"@types/node": "22.13.5",
2323
"@types/react": "19.0.10",
2424
"@types/react-dom": "19.0.4",
2525
"clsx": "^2.1.1",

examples/todo-app/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@
6767
"@react-navigation/native-stack": "^7.0.0",
6868
"@testing-library/dom": "^10.4.0",
6969
"@testing-library/jest-dom": "^6.6.3",
70-
"@testing-library/jest-native": "^5.4.3",
7170
"@testing-library/react": "16.2.0",
7271
"@testing-library/react-hooks": "8.0.1",
7372
"@testing-library/react-native": "13.0.1",
7473
"@types/jest": "29.5.14",
75-
"@types/node": "22.13.4",
74+
"@types/node": "22.13.5",
7675
"@types/react": "19.0.10",
7776
"@types/react-dom": "19.0.4",
7877
"babel-plugin-module-resolver": "5.0.2",
@@ -97,7 +96,7 @@
9796
"prettier": "3.5.2",
9897
"react": "19.0.0",
9998
"react-dom": "19.0.0",
100-
"react-native": "0.77.1",
99+
"react-native": "0.78.0",
101100
"react-native-safe-area-context": "^5.0.0",
102101
"react-native-screens": "^4.1.0",
103102
"react-test-renderer": "^19.0.0",

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"qs": "^6.13.1",
208208
"react": "19.0.0",
209209
"react-dom": "^19.0.0",
210-
"react-native": "0.77.1",
210+
"react-native": "0.78.0",
211211
"react-native-safe-area-context": "^5.0.0",
212212
"react-native-screens": "^4.1.0",
213213
"react-test-renderer": "^19.0.0",

packages/react/src/__tests__/integration-garbage-collection.native.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { MockResolver } from '@data-client/test';
88
import { render, screen, act, fireEvent } from '@testing-library/react-native';
99
import { ArticleResource } from '__tests__/new';
1010
import { useState } from 'react';
11-
import '@testing-library/jest-native';
1211
import {
1312
View,
1413
Text,
@@ -89,18 +88,25 @@ const TestComponent = () => {
8988
describe('Integration Garbage Collection React Native', () => {
9089
it('should render list view and detail view correctly', async () => {
9190
jest.useFakeTimers();
92-
mockGetList.mockResolvedValue([
91+
92+
mockGetList.mockReturnValue([
9393
{ id: 1, title: 'Article 1', content: 'Content 1' },
9494
{ id: 2, title: 'Article 2', content: 'Content 2' },
9595
]);
96-
mockGet.mockResolvedValue({
96+
mockGet.mockReturnValue({
9797
id: 1,
9898
title: 'Article 1',
9999
content: 'Content 1',
100100
});
101101

102102
render(<TestComponent />);
103103

104+
await act(async () => {
105+
jest.advanceTimersByTime(1000);
106+
InteractionManager.setDeadline(0);
107+
await jest.runOnlyPendingTimersAsync();
108+
});
109+
104110
// Initial render, should show list view
105111
expect(await screen.findByText('Article 1')).toBeTruthy();
106112

@@ -132,11 +138,15 @@ describe('Integration Garbage Collection React Native', () => {
132138
});
133139

134140
// Jest time pass to expiry
135-
act(() => {
141+
await act(async () => {
136142
jest.advanceTimersByTime(
137-
ArticleResource.getList.dataExpiryLength ?? 60000,
143+
Math.max(
144+
ArticleResource.getList.dataExpiryLength ?? 60000,
145+
GC_INTERVAL,
146+
),
138147
);
139148
InteractionManager.setDeadline(0);
149+
await jest.runOnlyPendingTimersAsync();
140150
});
141151

142152
expect(await screen.findByText('Content 1')).toBeTruthy();
@@ -154,6 +164,7 @@ describe('Integration Garbage Collection React Native', () => {
154164
});
155165

156166
expect(screen.getByText('Loading...')).toBeTruthy();
167+
await jest.runOnlyPendingTimersAsync();
157168
jest.useRealTimers();
158169
});
159170
});

packages/react/src/hooks/__tests__/subscriptions.native.tsx

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,11 @@ import {
77
ArticleResource,
88
Article,
99
} from '__tests__/new';
10-
import nock from 'nock';
1110

1211
import { makeRenderDataClient } from '../../../../test';
1312
import { ControllerContext } from '../../context';
1413
import useSubscription from '../useSubscription';
1514

16-
function jsonNock() {
17-
return nock(/.*/).defaultReplyHeaders({
18-
'Access-Control-Allow-Origin': '*',
19-
'Content-Type': 'application/json',
20-
});
21-
}
22-
2315
describe.each([
2416
['CacheProvider', CacheProvider],
2517
['ExternalDataProvider', ExternalDataProvider],
@@ -43,6 +35,7 @@ describe.each([
4335
content: string;
4436
tags: string[];
4537
},
38+
responseMock: jest.Mock,
4639
waitFor: <T>(callback: () => Promise<T> | T, options?: any) => Promise<T>,
4740
) {
4841
// should be null to start
@@ -55,16 +48,12 @@ describe.each([
5548
expect(result.current).toBeInstanceOf(Article);
5649
expect(result.current).toEqual(Article.fromJS(articlePayload));
5750
// should update again after frequency
58-
const fiverNock = jsonNock()
59-
.get(`/article/${articlePayload.id}`)
60-
.reply(200, { ...articlePayload, title: 'fiver' });
51+
responseMock.mockReturnValue({ ...articlePayload, title: 'fiver' });
6152

6253
jest.advanceTimersByTime(frequency);
6354

64-
await waitFor(() => expect(fiverNock.isDone()).toBeTruthy());
65-
jest.useRealTimers();
6655
await renderDataClient.allSettled();
67-
expect((result.current as any).title).toBe('fiver');
56+
await waitFor(() => expect((result.current as any).title).toBe('fiver'));
6857
}
6958

7059
function onError(e: any) {
@@ -85,35 +74,20 @@ describe.each([
8574
});
8675

8776
beforeEach(() => {
88-
nock(/.*/)
89-
.persist()
90-
.defaultReplyHeaders({
91-
'Access-Control-Allow-Origin': '*',
92-
'Content-Type': 'application/json',
93-
})
94-
.options(/.*/)
95-
.reply(200);
96-
97-
jsonNock()
98-
.get(`/article-cooler/${articlePayload.id}`)
99-
.reply(200, articlePayload)
100-
.get(`/article/${articlePayload.id}`)
101-
.reply(200, articlePayload);
10277
renderDataClient = makeRenderDataClient(makeProvider);
10378
});
10479
afterEach(() => {
10580
renderDataClient.cleanup();
106-
nock.cleanAll();
10781
jest.useRealTimers();
10882
});
10983

11084
it('useSubscription() + useCache()', async () => {
111-
jest.useFakeTimers({
112-
legacyFakeTimers: true,
113-
});
85+
jest.useFakeTimers();
11486
const frequency = PollingArticleResource.get.pollFrequency as number;
11587
expect(frequency).toBeDefined();
11688

89+
const responseMock = jest.fn(({ id }) => articlePayload);
90+
11791
const { result, rerender, waitFor } = renderDataClient(
11892
({ active }) => {
11993
useSubscription(
@@ -122,30 +96,47 @@ describe.each([
12296
);
12397
return useCache(PollingArticleResource.get, { id: articlePayload.id });
12498
},
125-
{ initialProps: { active: true } },
99+
{
100+
initialProps: { active: true },
101+
resolverFixtures: [
102+
{
103+
endpoint: PollingArticleResource.get,
104+
response: responseMock,
105+
},
106+
],
107+
},
126108
);
127109

128-
await validateSubscription(result, frequency, articlePayload, waitFor);
129-
110+
await validateSubscription(
111+
result,
112+
frequency,
113+
articlePayload,
114+
responseMock,
115+
waitFor,
116+
);
130117
// should not update if active is false
118+
responseMock.mockReturnValue({ ...articlePayload, title: 'sixer' });
119+
131120
rerender({ active: false });
132-
jsonNock()
133-
.get(`/article/${articlePayload.id}`)
134-
.reply(200, { ...articlePayload, title: 'sixer' });
135121
jest.advanceTimersByTime(frequency);
136122
expect((result.current as any).title).toBe('fiver');
137123

138124
// errors should not fail when data already exists
139-
nock.cleanAll();
140-
jsonNock()
141-
.get(`/article/${articlePayload.id}`)
142-
.reply(403, () => {
143-
return { message: 'you fail' };
144-
});
125+
responseMock.mockImplementation(({ id }) => {
126+
const error: any = new Error('you fail');
127+
error.status = 403;
128+
throw error;
129+
});
130+
const fetchCount = responseMock.mock.calls.length;
145131
rerender({ active: true });
146132
jest.advanceTimersByTime(frequency);
147-
expect((result.current as any).title).toBe('fiver');
133+
await waitFor(() =>
134+
expect(responseMock.mock.calls.length > fetchCount).toBeTruthy(),
135+
);
148136
jest.useRealTimers();
137+
await renderDataClient.allSettled();
138+
139+
expect((result.current as any).title).toBe('fiver');
149140
});
150141

151142
it('should console.error() with no frequency specified', async () => {
@@ -163,20 +154,37 @@ describe.each([
163154
});
164155

165156
it('useSubscription() without active arg', async () => {
166-
jest.useFakeTimers({
167-
legacyFakeTimers: true,
168-
});
157+
jest.useFakeTimers();
169158
const frequency = PollingArticleResource.get.pollFrequency as number;
170159
expect(frequency).toBeDefined();
171160
expect(PollingArticleResource.anotherGet.pollFrequency).toBeDefined();
172161

173-
const { result, waitFor } = renderDataClient(() => {
174-
useSubscription(PollingArticleResource.get, { id: articlePayload.id });
175-
return useCache(PollingArticleResource.get, { id: articlePayload.id });
176-
});
162+
const responseMock = jest.fn(({ id }) => articlePayload);
163+
164+
const { result, waitFor } = renderDataClient(
165+
() => {
166+
useSubscription(PollingArticleResource.get, { id: articlePayload.id });
167+
return useCache(PollingArticleResource.get, { id: articlePayload.id });
168+
},
169+
{
170+
resolverFixtures: [
171+
{
172+
endpoint: PollingArticleResource.get,
173+
response: responseMock,
174+
},
175+
],
176+
},
177+
);
177178

178-
await validateSubscription(result, frequency, articlePayload, waitFor);
179+
await validateSubscription(
180+
result,
181+
frequency,
182+
articlePayload,
183+
responseMock,
184+
waitFor,
185+
);
179186
await renderDataClient.allSettled();
187+
jest.useRealTimers();
180188
});
181189

182190
it('useSubscription() should dispatch data-client/subscribe only once even with rerender', async () => {

0 commit comments

Comments
 (0)