Skip to content

Commit 4a9ab2d

Browse files
committed
Fix tests (#13)
* refactor: use jest for tests I couldn’t find a way to fix our tests and make them work with tamagui. Vitest is ignoring the native.ts files that tamagui has and tests were failing, because of that I reconfigured the project to use jest. * fix: button test * feat: add container tests * feat: add DataRow tests
1 parent 8a244b9 commit 4a9ab2d

19 files changed

+4381
-2209
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ web-build/
1313
# Auto generated storybook file
1414
.storybook/storybook.requires.ts
1515

16-
# From vitest:ui
16+
# From jest
1717
html
1818
coverage
1919

@@ -26,3 +26,5 @@ coverage
2626
expo-env.d.ts
2727
# @end expo-cli
2828
/.idea
29+
# Tamagui UI generates a lot of cache files
30+
.tamagui

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ detox test --configuration android.emu.debug
9898

9999
## Unit tests
100100

101-
We use (Vitest)[https://vitest.dev/] for running our unit/component/hook tests and [React Native Testing Library](https://callstack.github.io/react-native-testing-library/) to manipulate them.
101+
We use Jest for running our unit/component/hook tests and [React Native Testing Library](https://callstack.github.io/react-native-testing-library/) to manipulate them.
102102

103103
To run the tests you can just type in your terminal:
104104

@@ -112,11 +112,12 @@ npm run test
112112
npm run test:watch
113113
```
114114

115-
#### checking the coverage and ui
115+
#### checking the coverage
116116

117117
```bash
118-
npm run test:ui
118+
npm run test
119119
```
120+
navigate inside the coverage folder and open the index.html file in your browser
120121

121122
## Running Eslint & Prettier
122123

__mocks__/fileMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'test-file-stub';

babel.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
module.exports = function (api) {
2-
api.cache(true);
2+
api.cache(true)
33
return {
44
presets: ['babel-preset-expo'],
5-
env: {
6-
production: {
7-
plugins: ['react-native-paper/babel'],
8-
},
9-
},
10-
};
11-
};
5+
}
6+
}

jest.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
preset: 'jest-expo',
3+
collectCoverage: true,
4+
collectCoverageFrom: [
5+
'./src/**',
6+
'!./src/**/*.stories.{js,jsx,ts,tsx}',
7+
'!./src/tests/**',
8+
'!./src/types/**',
9+
'!./src/**/*.snap',
10+
],
11+
coverageReporters: ['json', 'html', 'text-summary'],
12+
setupFilesAfterEnv: ['./src/tests/jest.setup.ts', './src/tests/test-utils.tsx'],
13+
moduleNameMapper: {
14+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
15+
'<rootDir>/__mocks__/fileMock.js',
16+
},
17+
transformIgnorePatterns: [
18+
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|react-redux)',
19+
],
20+
testPathIgnorePatterns: ['/node_modules/', '/e2e/'],
21+
}

0 commit comments

Comments
 (0)