Skip to content

Commit 7280311

Browse files
committed
Merge branch 'main' into poc/custom-renderer
# Conflicts: # package.json # src/fire-event.ts # src/helpers/component-tree.ts # src/matchers/__tests__/to-be-checked.test.tsx # src/matchers/__tests__/to-be-partially-checked.test.tsx # src/render.tsx # src/user-event/utils/dispatch-event.ts # yarn.lock
2 parents 8e521ff + df215c7 commit 7280311

File tree

106 files changed

+5906
-960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+5906
-960
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,26 @@ jobs:
5656
uses: ./.github/actions/setup-deps
5757

5858
- name: Test
59-
run: yarn test:ci
59+
run: yarn test:ci:coverage
6060

6161
- name: Upload coverage to Codecov
6262
uses: codecov/codecov-action@v4
6363

64+
65+
test-concurrent:
66+
needs: [install-cache-deps]
67+
runs-on: ubuntu-latest
68+
name: Test (concurrent mode)
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@v4
72+
73+
- name: Setup Node.js and deps
74+
uses: ./.github/actions/setup-deps
75+
76+
- name: Test in concurrent mode
77+
run: CONCURRENT_MODE=1 yarn test:ci
78+
6479
test-website:
6580
runs-on: ubuntu-latest
6681
name: Test Website

.release-it.json

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
11
{
2+
"hooks": {
3+
"before:init": ["yarn typecheck", "yarn test", "yarn lint"],
4+
"after:bump": "yarn build",
5+
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
6+
},
27
"git": {
3-
"commitMessage": "chore: release ${version}",
8+
"commitMessage": "chore: release v${version}",
49
"tagName": "v${version}"
510
},
611
"npm": {
712
"publish": true
813
},
914
"github": {
10-
"release": true
15+
"release": true,
16+
"releaseName": "v${version}"
1117
},
1218
"plugins": {
1319
"@release-it/conventional-changelog": {
14-
"preset": "angular"
20+
"preset": {
21+
"name": "conventionalcommits",
22+
"types": [
23+
{
24+
"type": "feat",
25+
"section": "✨ Features"
26+
},
27+
{
28+
"type": "perf",
29+
"section": "💨 Performance Improvements"
30+
},
31+
{
32+
"type": "fix",
33+
"section": "🐛 Bug Fixes"
34+
},
35+
{
36+
"type": "chore(deps)",
37+
"section": "🛠️ Dependency Upgrades"
38+
},
39+
{
40+
"type": "docs",
41+
"section": "📚 Documentation"
42+
}
43+
]
44+
}
1545
}
1646
}
1747
}

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import '@testing-library/react-native/extend-expect';
5353
## Example
5454

5555
```jsx
56-
import { render, screen, fireEvent } from '@testing-library/react-native';
56+
import { render, screen, userEvent } from '@testing-library/react-native';
5757
import { QuestionsBoard } from '../QuestionsBoard';
5858

5959
// It is recommended to use userEvent with fake timers
@@ -109,7 +109,6 @@ React Native Testing Library consists of following APIs:
109109
- [Migration to 12.0](https://callstack.github.io/react-native-testing-library/docs/migration/v12)
110110
- [Migration to built-in Jest Matchers](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers)
111111

112-
113112
## Troubleshooting
114113

115114
- [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/guides/troubleshooting)

examples/basic/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jest-setup.ts
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as React from 'react';
2+
import { Animated, ViewStyle } from 'react-native';
3+
4+
type AnimatedViewProps = {
5+
fadeInDuration?: number;
6+
style?: ViewStyle;
7+
children: React.ReactNode;
8+
useNativeDriver?: boolean;
9+
};
10+
11+
export function AnimatedView(props: AnimatedViewProps) {
12+
const fadeAnim = React.useRef(new Animated.Value(0)).current; // Initial value for opacity: 0
13+
14+
React.useEffect(() => {
15+
Animated.timing(fadeAnim, {
16+
toValue: 1,
17+
duration: props.fadeInDuration ?? 250,
18+
useNativeDriver: props.useNativeDriver ?? true,
19+
}).start();
20+
}, [fadeAnim, props.fadeInDuration, props.useNativeDriver]);
21+
22+
return (
23+
<Animated.View
24+
style={{
25+
...props.style,
26+
opacity: fadeAnim,
27+
}}
28+
>
29+
{props.children}
30+
</Animated.View>
31+
);
32+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as React from 'react';
2+
import { Text } from 'react-native';
3+
import { act, render, screen } from '@testing-library/react-native';
4+
import { AnimatedView } from '../AnimatedView';
5+
6+
describe('AnimatedView', () => {
7+
beforeEach(() => {
8+
jest.useFakeTimers();
9+
});
10+
11+
afterEach(() => {
12+
jest.useRealTimers();
13+
});
14+
15+
it('should use native driver when useNativeDriver is true', async () => {
16+
render(
17+
<AnimatedView fadeInDuration={250} useNativeDriver={true}>
18+
<Text>Test</Text>
19+
</AnimatedView>,
20+
);
21+
expect(screen.root).toHaveStyle({ opacity: 0 });
22+
23+
await act(() => jest.advanceTimersByTime(250));
24+
expect(screen.root).toHaveStyle({ opacity: 1 });
25+
});
26+
27+
it('should not use native driver when useNativeDriver is false', async () => {
28+
render(
29+
<AnimatedView fadeInDuration={250} useNativeDriver={false}>
30+
<Text>Test</Text>
31+
</AnimatedView>,
32+
);
33+
expect(screen.root).toHaveStyle({ opacity: 0 });
34+
35+
await act(() => jest.advanceTimersByTime(250));
36+
expect(screen.root).toHaveStyle({ opacity: 1 });
37+
});
38+
});

examples/basic/jest-setup.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
/* eslint-disable no-undef, import/no-extraneous-dependencies */
1+
import { configure } from '@testing-library/react-native';
22

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

66
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
77
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
8+
9+
configure({ concurrentRoot: true });

examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"devDependencies": {
2222
"@babel/core": "^7.24.0",
23-
"@testing-library/react-native": "^12.7.1",
23+
"@testing-library/react-native": "^12.8.0",
2424
"@types/eslint": "^8.56.10",
2525
"@types/jest": "^29.5.12",
2626
"@types/react": "~18.2.79",

examples/basic/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,9 +2463,9 @@ __metadata:
24632463
languageName: node
24642464
linkType: hard
24652465

2466-
"@testing-library/react-native@npm:^12.7.1":
2467-
version: 12.7.1
2468-
resolution: "@testing-library/react-native@npm:12.7.1"
2466+
"@testing-library/react-native@npm:^12.8.0":
2467+
version: 12.8.0
2468+
resolution: "@testing-library/react-native@npm:12.8.0"
24692469
dependencies:
24702470
jest-matcher-utils: "npm:^29.7.0"
24712471
pretty-format: "npm:^29.7.0"
@@ -2478,7 +2478,7 @@ __metadata:
24782478
peerDependenciesMeta:
24792479
jest:
24802480
optional: true
2481-
checksum: 10c0/caaa4bdf97834b307b72af05c447ce40a2ba2ff40b464050bc29535caadf81981ea2873668445e633fdb3d13efccb136ef0932d6d9f4736bc6f7f98be98088d4
2481+
checksum: 10c0/216d40eefc3afa3259b37611213dcd6667cd0b8deb30521a8aaabe3afc15f07116ce64acba150f8c88b8e268df80639baf6bc38f05af1dbbae247e1d07639bde
24822482
languageName: node
24832483
linkType: hard
24842484

@@ -8923,7 +8923,7 @@ __metadata:
89238923
resolution: "root-workspace-0b6124@workspace:."
89248924
dependencies:
89258925
"@babel/core": "npm:^7.24.0"
8926-
"@testing-library/react-native": "npm:^12.7.1"
8926+
"@testing-library/react-native": "npm:^12.8.0"
89278927
"@types/eslint": "npm:^8.56.10"
89288928
"@types/jest": "npm:^29.5.12"
89298929
"@types/react": "npm:~18.2.79"

examples/cookbook/.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
test-utils.*
1+
jest-setup.ts
2+
test-utils.*

0 commit comments

Comments
 (0)