Skip to content

Commit 3e0b66b

Browse files
Fix tests
1 parent 190cb25 commit 3e0b66b

File tree

7 files changed

+633
-130
lines changed

7 files changed

+633
-130
lines changed

.eslintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
"node": true,
44
"react-native/react-native": true
55
},
6+
"overrides": [
7+
{
8+
// Test files only
9+
"files": ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
10+
"extends": ["plugin:testing-library/react"]
11+
}
12+
],
613
"extends": [
714
"eslint:recommended",
815
"plugin:import/recommended",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @format
3+
*/
4+
/* eslint-env jest */
5+
6+
jest.mock('@react-native-clipboard/clipboard', () => {
7+
return {
8+
addListener: jest.fn(),
9+
removeAllListeners: jest.fn(),
10+
};
11+
});

__tests__/App.test.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
/**
22
* @format
33
*/
4-
// Note: import explicitly to use the types shipped with jest.
5-
import React from 'react';
6-
// Note: test renderer must be required after react-native.
7-
import renderer from 'react-test-renderer';
4+
/* eslint-env jest */
85

96
import App from '@/App';
107

11-
import 'react-native';
128
import { it } from '@jest/globals';
9+
import { render } from '@testing-library/react-native';
1310

1411
it('renders correctly', () => {
15-
renderer.create(<App />);
12+
render(<App />);
1613
});

jest.setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
import '@testing-library/react-native/extend-expect';
2+
13
// eslint-disable-next-line no-global-assign
24
__DEV__ = false;

licenses.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
"licenseUrl": "https://github.com/Apercu/react-native-zeroconf/raw/master/LICENSE",
270270
"parents": "opendtu-react-native"
271271
},
272-
272+
273273
"licenses": "MIT",
274274
"repository": "https://github.com/facebook/react-native",
275275
"licenseUrl": "https://github.com/facebook/react-native/raw/master/LICENSE",

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@
9090
"@babel/plugin-transform-private-methods": "^7.24.1",
9191
"@babel/preset-env": "^7.24.5",
9292
"@babel/runtime": "^7.24.5",
93-
"@react-native/babel-preset": "0.74.83",
94-
"@react-native/eslint-config": "0.74.83",
95-
"@react-native/metro-config": "0.74.83",
96-
"@react-native/typescript-config": "0.74.83",
93+
"@react-native/babel-preset": "0.74.84",
94+
"@react-native/eslint-config": "0.74.84",
95+
"@react-native/metro-config": "0.74.84",
96+
"@react-native/typescript-config": "0.74.84",
97+
"@testing-library/react-native": "^12.5.1",
9798
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
99+
"@types/jest": "^29.5.12",
98100
"@types/markdown-it": "^14.1.1",
99101
"@types/npm-license-crawler": "^0.2.3",
100102
"@types/react": "^18.3.2",
@@ -112,6 +114,7 @@
112114
"eslint-plugin-prettier": "5.1.3",
113115
"eslint-plugin-react-hooks": "^4.6.2",
114116
"eslint-plugin-simple-import-sort": "^12.1.0",
117+
"eslint-plugin-testing-library": "^6.2.2",
115118
"jest": "^29.7.0",
116119
"prettier": "^3.3.2",
117120
"react-native-version": "^4.0.0",

0 commit comments

Comments
 (0)