Skip to content

Commit

Permalink
chore: update RNTL in example apps (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjastrzebski authored Oct 25, 2024
1 parent bc083af commit 0c8f3a8
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions examples/basic/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest-setup.ts
2 changes: 1 addition & 1 deletion examples/basic/components/AnimatedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function AnimatedView(props: AnimatedViewProps) {
duration: props.fadeInDuration ?? 250,
useNativeDriver: props.useNativeDriver ?? true,
}).start();
}, [fadeAnim]);
}, [fadeAnim, props.fadeInDuration, props.useNativeDriver]);

return (
<Animated.View
Expand Down
6 changes: 4 additions & 2 deletions examples/basic/components/__tests__/AnimatedView.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as React from 'react';
import { Text } from 'react-native';
import { act, render, screen } from '@testing-library/react-native';
import { AnimatedView } from '../AnimatedView';

Expand All @@ -13,7 +15,7 @@ describe('AnimatedView', () => {
it('should use native driver when useNativeDriver is true', async () => {
render(
<AnimatedView fadeInDuration={250} useNativeDriver={true}>
Test
<Text>Test</Text>
</AnimatedView>,
);
expect(screen.root).toHaveStyle({ opacity: 0 });
Expand All @@ -25,7 +27,7 @@ describe('AnimatedView', () => {
it('should not use native driver when useNativeDriver is false', async () => {
render(
<AnimatedView fadeInDuration={250} useNativeDriver={false}>
Test
<Text>Test</Text>
</AnimatedView>,
);
expect(screen.root).toHaveStyle({ opacity: 0 });
Expand Down
4 changes: 3 additions & 1 deletion examples/basic/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable no-undef, import/no-extraneous-dependencies */
import { configure } from '@testing-library/react-native';

// Import built-in Jest matchers
import '@testing-library/react-native/extend-expect';

// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');

configure({ concurrentRoot: true });
2 changes: 1 addition & 1 deletion examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@testing-library/react-native": "^12.7.1",
"@testing-library/react-native": "^12.8.0",
"@types/eslint": "^8.56.10",
"@types/jest": "^29.5.12",
"@types/react": "~18.2.79",
Expand Down
10 changes: 5 additions & 5 deletions examples/basic/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2463,9 +2463,9 @@ __metadata:
languageName: node
linkType: hard

"@testing-library/react-native@npm:^12.7.1":
version: 12.7.1
resolution: "@testing-library/react-native@npm:12.7.1"
"@testing-library/react-native@npm:^12.8.0":
version: 12.8.0
resolution: "@testing-library/react-native@npm:12.8.0"
dependencies:
jest-matcher-utils: "npm:^29.7.0"
pretty-format: "npm:^29.7.0"
Expand All @@ -2478,7 +2478,7 @@ __metadata:
peerDependenciesMeta:
jest:
optional: true
checksum: 10c0/caaa4bdf97834b307b72af05c447ce40a2ba2ff40b464050bc29535caadf81981ea2873668445e633fdb3d13efccb136ef0932d6d9f4736bc6f7f98be98088d4
checksum: 10c0/216d40eefc3afa3259b37611213dcd6667cd0b8deb30521a8aaabe3afc15f07116ce64acba150f8c88b8e268df80639baf6bc38f05af1dbbae247e1d07639bde
languageName: node
linkType: hard

Expand Down Expand Up @@ -8923,7 +8923,7 @@ __metadata:
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@babel/core": "npm:^7.24.0"
"@testing-library/react-native": "npm:^12.7.1"
"@testing-library/react-native": "npm:^12.8.0"
"@types/eslint": "npm:^8.56.10"
"@types/jest": "npm:^29.5.12"
"@types/react": "npm:~18.2.79"
Expand Down
3 changes: 2 additions & 1 deletion examples/cookbook/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test-utils.*
jest-setup.ts
test-utils.*
6 changes: 5 additions & 1 deletion examples/cookbook/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-undef, import/no-extraneous-dependencies */
import { configure } from '@testing-library/react-native';

// Import built-in Jest matchers
import '@testing-library/react-native/extend-expect';
Expand All @@ -9,7 +9,11 @@ jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');

// Enable API mocking via Mock Service Worker (MSW)
beforeAll(() => server.listen());

// Reset any runtime request handlers we may add during the tests
afterEach(() => server.resetHandlers());

// Disable API mocking after the tests are done
afterAll(() => server.close());

configure({ concurrentRoot: true });
2 changes: 1 addition & 1 deletion examples/cookbook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@expo/metro-runtime": "~3.2.3",
"@testing-library/react-native": "^12.7.2",
"@testing-library/react-native": "^12.8.0",
"@types/eslint": "^8.56.10",
"@types/jest": "^29.5.12",
"@types/react": "~18.2.45",
Expand Down
10 changes: 5 additions & 5 deletions examples/cookbook/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2833,9 +2833,9 @@ __metadata:
languageName: node
linkType: hard

"@testing-library/react-native@npm:^12.7.2":
version: 12.7.2
resolution: "@testing-library/react-native@npm:12.7.2"
"@testing-library/react-native@npm:^12.8.0":
version: 12.8.0
resolution: "@testing-library/react-native@npm:12.8.0"
dependencies:
jest-matcher-utils: "npm:^29.7.0"
pretty-format: "npm:^29.7.0"
Expand All @@ -2848,7 +2848,7 @@ __metadata:
peerDependenciesMeta:
jest:
optional: true
checksum: 10c0/0e4e26bd211056646f8b5c80e9177efc90affe0ddc7e1a2c22742a4e6da7129ec1f9125c7d233adddeb27f429fb3eb91e3f3bfa9e77e176f042475574546b001
checksum: 10c0/216d40eefc3afa3259b37611213dcd6667cd0b8deb30521a8aaabe3afc15f07116ce64acba150f8c88b8e268df80639baf6bc38f05af1dbbae247e1d07639bde
languageName: node
linkType: hard

Expand Down Expand Up @@ -9762,7 +9762,7 @@ __metadata:
dependencies:
"@babel/core": "npm:^7.20.0"
"@expo/metro-runtime": "npm:~3.2.3"
"@testing-library/react-native": "npm:^12.7.2"
"@testing-library/react-native": "npm:^12.8.0"
"@types/eslint": "npm:^8.56.10"
"@types/jest": "npm:^29.5.12"
"@types/react": "npm:~18.2.45"
Expand Down

0 comments on commit 0c8f3a8

Please sign in to comment.