Skip to content

Commit 1c60b81

Browse files
committed
chore: updated jest setup and jest config
1 parent 3fc3583 commit 1c60b81

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

template/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = {
3434
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
3535
'@typescript-eslint/explicit-module-boundary-types': 0,
3636
'react/display-name': 0,
37+
'jest/expect-expect': 0,
3738
},
3839
settings: {
3940
react: {

template/jest.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@ module.exports = {
22
preset: 'react-native',
33
testEnvironment: 'node',
44
setupFilesAfterEnv: ['./jest.setup'],
5+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
6+
transformIgnorePatterns: [
7+
'node_modules/(?!(@react-native|react-native|react-native-vector-icons|react-native-iphone-x-helper|react-native-flipper|@react-native-community|@react-navigation|.|react-navigation|react-native-animatable)/)',
8+
],
9+
moduleNameMapper: {
10+
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
11+
'jest-transform-stub',
12+
'\\.(css|less)$': 'identity-obj-proxy',
13+
'^styled-components$': '<rootDir>/node_modules/styled-components',
14+
},
15+
setupFiles: ['./node_modules/react-native-gesture-handler/jestSetup.js'],
516
};

template/jest.setup.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ import '@testing-library/jest-native/extend-expect';
22

33
import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js';
44
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
5-
5+
import 'jest-styled-components';
6+
import * as styledSystem from 'styled-system';
67
import { jest } from '@jest/globals';
78

9+
jest.useFakeTimers();
10+
811
jest.mock('@react-native-community/netinfo', () => mockRNCNetInfo);
912
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
1013

14+
jest.doMock('styled-system');
15+
jest.doMock('react-native-animatable');
16+
17+
styledSystem.theme = jest.fn().mockImplementation((k) => k); //
18+
1119
jest.doMock('@sentry/react-native', () => ({
1220
init: jest.fn(),
1321
}));

template/jest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ else
1111
fi
1212

1313
echo "Executing jest tests... with $WORKERS workers"
14-
npx jest --maxWorkers=$WORKERS;
14+
npx jest --maxWorkers=$WORKERS --watch;
1515
exit

0 commit comments

Comments
 (0)