Browse Source

Unit testing lib Jest install and setup

master
GabrielTrettel 4 years ago
parent
commit
2a75be876b
  1. 14
      src/__test__/App.test.js
  2. 13
      src/package.json

14
src/__test__/App.test.js

@ -0,0 +1,14 @@
import React from "react";
import renderer from "react-test-renderer";
import App from "../App";
//FIXME:currently, I can't run the example that is in the expo documentation
// -> https://docs.expo.io/guides/testing-with-jest/#unit-test
// NOTE: Just an toy example for verifying if Jest is running
describe("<App />", () => {
it("has 1 child", () => {
// const tree = renderer.create(<App />).toJSON();
expect(1 + 1).toBe(2);
});
});

13
src/package.json

@ -5,7 +5,14 @@
"android": "expo start --android", "android": "expo start --android",
"ios": "expo start --ios", "ios": "expo start --ios",
"web": "expo start --web", "web": "expo start --web",
"eject": "expo eject"
"eject": "expo eject",
"test": "jest"
},
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)"
]
}, },
"dependencies": { "dependencies": {
"@expo/metro-config": "^0.1.44", "@expo/metro-config": "^0.1.44",
@ -43,7 +50,9 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-loader": "^8.2.2"
"babel-loader": "^8.2.2",
"jest-expo": "^40.0.1",
"react-test-renderer": "^17.0.1"
}, },
"private": true "private": true
} }
Loading…
Cancel
Save