Merge pull request 'Add jest for unit tests' (#8) from add-jest into master
Reviewed-on: billnerds/rn-playground#8
This commit is contained in:
commit
002ac7902d
@ -21,3 +21,5 @@ jobs:
|
||||
run: nix develop --impure --command bash -c 'export HOME=$PWD; yarn run lint'
|
||||
- name: typecheck
|
||||
run: nix develop --impure --command bash -c 'export HOME=$PWD; yarn tsc --noEmit'
|
||||
- name: test
|
||||
run: nix develop --impure --command bash -c 'export HOME=$PWD; yarn run test --no-watchman'
|
||||
|
14
App.tsx
Normal file
14
App.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from "react";
|
||||
import { SafeAreaView, Text } from "react-native";
|
||||
|
||||
|
||||
const App: React.FC = () => {
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Text>Hello, World!</Text>
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default App;
|
13
package.json
13
package.json
@ -10,8 +10,14 @@
|
||||
"lint": "eslint . --ext .js,.ts,.tsx",
|
||||
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
||||
"start:dev": "ENVFILE=.env.development react-native start",
|
||||
"start:prod": "ENVFILE=.env.production react-native start"
|
||||
"start:prod": "ENVFILE=.env.production react-native start",
|
||||
"test": "jest"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "jest-expo",
|
||||
"transformIgnorePatterns": [
|
||||
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
|
||||
]},
|
||||
"dependencies": {
|
||||
"@types/react": "~18.2.14",
|
||||
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
||||
@ -22,13 +28,16 @@
|
||||
"eslint-plugin-react-native": "^4.1.0",
|
||||
"expo": "~49.0.15",
|
||||
"expo-status-bar": "~1.6.0",
|
||||
"jest": "^29.2.1",
|
||||
"jest-expo": "~49.0.0",
|
||||
"react": "18.2.0",
|
||||
"react-native": "0.72.6",
|
||||
"react-native-dotenv": "^3.4.9",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.0"
|
||||
"@babel/core": "^7.20.0",
|
||||
"@types/jest": "^29.5.11"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
12
tests/App.test.tsx
Normal file
12
tests/App.test.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from "react";
|
||||
import renderer from "react-test-renderer";
|
||||
|
||||
import App from "../App";
|
||||
|
||||
|
||||
describe("<App />", () => {
|
||||
it("has 1 child", () => {
|
||||
const tree = renderer.create(<App />).toJSON();
|
||||
expect(tree.children.length).toBe(1);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user