Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for testing with react@17 #1115

Merged
merged 5 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ jobs:
- store_artifacts:
path: coverage
destination: coverage
test:react:17:
<<: *defaults
steps:
- attach_workspace:
at: ~/react-native-testing-library
- run: |
yarn test:ci:react:17
test-website:
<<: *defaults
steps:
Expand Down Expand Up @@ -91,6 +98,9 @@ workflows:
- tests:
requires:
- install-dependencies
- test:react:17:
requires:
- install-dependencies
- test-website:
requires:
- install-dependencies
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"clean": "del build",
"test": "jest",
"test:ci": "jest --maxWorkers=2",
"test:ci:react:17": "scripts/test_react_17",
"typecheck": "tsc",
"flow": "flow",
"copy-flowtypes": "cp typings/index.flow.js build",
Expand Down
12 changes: 12 additions & 0 deletions scripts/test_react_17
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

cp yarn.lock yarn.lock.backup
cp package.json package.json.backup

yarn add -D react@17.0.2 react-test-renderer@17.0.2 react-native@0.68.3 --ignore-scripts
yarn test:ci

mv package.json.backup package.json
mv yarn.lock.backup yarn.lock

yarn --ignore-scripts
12 changes: 6 additions & 6 deletions src/__tests__/render.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ test('debug changing component', () => {
test('renders options.wrapper around node', () => {
type WrapperComponentProps = { children: React.ReactNode };
const WrapperComponent = ({ children }: WrapperComponentProps) => (
<SafeAreaView testID="wrapper">{children}</SafeAreaView>
<View testID="wrapper">{children}</View>
mdjastrzebski marked this conversation as resolved.
Show resolved Hide resolved
);

const { toJSON, getByTestId } = render(<View testID="inner" />, {
Expand All @@ -214,20 +214,20 @@ test('renders options.wrapper around node', () => {

expect(getByTestId('wrapper')).toBeTruthy();
expect(toJSON()).toMatchInlineSnapshot(`
<RCTSafeAreaView
<View
testID="wrapper"
>
<View
testID="inner"
/>
</RCTSafeAreaView>
</View>
`);
});

test('renders options.wrapper around updated node', () => {
type WrapperComponentProps = { children: React.ReactNode };
const WrapperComponent = ({ children }: WrapperComponentProps) => (
<SafeAreaView testID="wrapper">{children}</SafeAreaView>
<View testID="wrapper">{children}</View>
);

const { toJSON, getByTestId, rerender } = render(<View testID="inner" />, {
Expand All @@ -240,15 +240,15 @@ test('renders options.wrapper around updated node', () => {

expect(getByTestId('wrapper')).toBeTruthy();
expect(toJSON()).toMatchInlineSnapshot(`
<RCTSafeAreaView
<View
testID="wrapper"
>
<View
accessibilityHint="test"
accessibilityLabel="test"
testID="inner"
/>
</RCTSafeAreaView>
</View>
`);
});

Expand Down