Skip to content
This repository was archived by the owner on Dec 3, 2022. It is now read-only.

Commit 497424d

Browse files
committed
fixed jest setup
1 parent e78920e commit 497424d

File tree

7 files changed

+25
-37
lines changed

7 files changed

+25
-37
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ android/keystores/debug.keystore
5151
# Test
5252
coverage/
5353
.jest/
54+
**/__snapshots__/**
55+

jest.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ module.exports = {
1212
babelConfig: true,
1313
},
1414
},
15-
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
15+
testPathIgnorePatterns: [
16+
"\\.snap$",
17+
"<rootDir>/node_modules/",
18+
"<rootDir>/dist/"
19+
],
20+
transformIgnorePatterns: [
21+
"<rootDir>/node_modules/(?!react-native)/"
22+
],
1623
cacheDirectory: '.jest/cache',
1724
};

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@
3030
"url": "https://github.com/react-navigation/react-navigation-hooks/issues"
3131
},
3232
"homepage": "https://github.com/react-navigation/react-navigation-hooks#readme",
33-
"dependencies": {
34-
"@babel/core": "^7.1.6",
35-
"babel-core": "^7.0.0-bridge.0",
36-
"babel-jest": "^23.6.0"
37-
},
3833
"devDependencies": {
3934
"@react-navigation/core": "^3.0.0",
35+
"@react-navigation/native": "^3.0.2",
4036
"@types/jest": "^23.3.9",
4137
"@types/react": "^16.7.7",
4238
"@types/react-native": "^0.57.14",
@@ -49,7 +45,6 @@
4945
"pretty-quick": "^1.8.0",
5046
"react": "^16.7.0-alpha.2",
5147
"react-native": "^0.57.7",
52-
"react-navigation": "^3.0.4",
5348
"react-navigation-types-only": "bySabi/react-navigation#patch-1",
5449
"react-test-renderer": "^16.7.0-alpha.2",
5550
"release-it": "^7.6.1",

src/__tests__/Hooks-test.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import * as React from 'react';
22
import { View, Button } from 'react-native';
33
import * as renderer from 'react-test-renderer';
4-
// TODO: Remove "react-navigation-types-only" when https://github.com/react-navigation/react-navigation/pull/5276
5-
// get merged
6-
// import { NavigationScreenProp } from "react-navigation-types-only";
7-
import { createStackNavigator, createAppContainer } from 'react-navigation';
4+
import { createSwitchNavigator } from '@react-navigation/core';
5+
import { createAppContainer } from '@react-navigation/native';
6+
87
import {
98
useNavigation
10-
} from '../../';
9+
} from '../../dist/Hooks';
1110

1211
const HomeScreen = () => {
1312
const { navigate } = useNavigation();
@@ -16,7 +15,7 @@ const HomeScreen = () => {
1615

1716
const DetailsScreen = () => <View />;
1817

19-
const AppNavigator = createStackNavigator(
18+
const AppNavigator = createSwitchNavigator(
2019
{
2120
Home: HomeScreen,
2221
Details: DetailsScreen,
@@ -35,7 +34,7 @@ describe('Navigating to a new screen', () => {
3534
expect(tree).toMatchSnapshot();
3635

3736
// Manually trigger onPress
38-
tree!.props.onPress();
37+
//tree!.props.onPress();
3938
tree = rendered.toJSON();
4039

4140
expect(rendered).toMatchSnapshot();

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"target": "es5",
44
"module": "commonjs",
55
"lib": ["es6"],
6-
"jsx": "react-native",
6+
"jsx": "react",
77
"sourceMap": true,
88
"moduleResolution": "node",
99
"rootDir": "src",

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"label-position": true,
4343
"max-line-length": [true, 120],
4444
"member-ordering": false,
45+
"no-empty": false,
4546
"no-any": false,
4647
"no-arg": true,
4748
"no-switch-case-fall-through": true,

yarn.lock

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
dependencies:
1010
"@babel/highlight" "^7.0.0"
1111

12-
"@babel/core@^7.0.0", "@babel/core@^7.1.6":
12+
"@babel/core@^7.0.0":
1313
version "7.1.6"
1414
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.1.6.tgz#3733cbee4317429bc87c62b29cf8587dba7baeb3"
1515
integrity sha512-Hz6PJT6e44iUNpAn8AoyAs6B3bl60g7MJQaI0rZEar6ECzh6+srYO1xlIdssio34mPaUtAb1y+XlkkSJzok3yw==
@@ -701,7 +701,7 @@
701701
universal-user-agent "^2.0.0"
702702
url-template "^2.0.8"
703703

704-
"@react-navigation/core@3.0.0", "@react-navigation/core@^3.0.0":
704+
"@react-navigation/core@^3.0.0":
705705
version "3.0.0"
706706
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.0.0.tgz#042c7fcb99331d7b452868d129b4e1cc3a4c60b9"
707707
integrity sha512-WZH4notU5tZNxtQ1Vl/y8Z0685+nWtyJlfqKf6ybZruah8BC+sml3tKoBqCHzUTybCfYtRT7pPuCgvlpADe3UQ==
@@ -713,7 +713,7 @@
713713
react-is "^16.5.2"
714714
react-lifecycles-compat "^3.0.4"
715715

716-
"@react-navigation/native@3.0.2", "@react-navigation/native@^3.0.1":
716+
"@react-navigation/native@^3.0.1", "@react-navigation/native@^3.0.2":
717717
version "3.0.2"
718718
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-3.0.2.tgz#3365846d54f7e0cf4a7e6bc9b5ef574bfe6774ce"
719719
integrity sha512-DGeP/EvLmoPxkfF9OQg5ZUgfiEA6vfQdYCL3VIkpw5pEVDO9LFvUih9N9ZWcGLBhn6eEXUa4Dx7cyUnvFp04nQ==
@@ -1158,11 +1158,6 @@ babel-core@^6.0.0, babel-core@^6.26.0:
11581158
slash "^1.0.0"
11591159
source-map "^0.5.7"
11601160

1161-
babel-core@^7.0.0-bridge.0:
1162-
version "7.0.0-bridge.0"
1163-
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
1164-
integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==
1165-
11661161
babel-generator@^6.18.0, babel-generator@^6.26.0:
11671162
version "6.26.1"
11681163
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90"
@@ -6721,19 +6716,19 @@ react-native@^0.57.7:
67216716
xmldoc "^0.4.0"
67226717
yargs "^9.0.0"
67236718

6724-
react-navigation-drawer@1.0.4, react-navigation-drawer@^1.0.1:
6719+
react-navigation-drawer@^1.0.1:
67256720
version "1.0.4"
67266721
resolved "https://registry.yarnpkg.com/react-navigation-drawer/-/react-navigation-drawer-1.0.4.tgz#41fbf71db108b3183e0c0351bf19ffee0aea10e7"
67276722
integrity sha512-P+3FgiYX2iQIkXeYCg7hOfg7u9fYBLWjqb1k6ILxML9VBimPXXM+87/lnIsfkZVOm4FIoH/ZAofbkPa7rYeJcQ==
67286723
dependencies:
67296724
react-native-tab-view "^1.2.0"
67306725

6731-
react-navigation-stack@1.0.4, react-navigation-stack@^1.0.1:
6726+
react-navigation-stack@^1.0.1:
67326727
version "1.0.4"
67336728
resolved "https://registry.yarnpkg.com/react-navigation-stack/-/react-navigation-stack-1.0.4.tgz#ec97ca34942e1001b6633690e26e33f86f26e0c3"
67346729
integrity sha512-wMLJkv1kUVXqdLp76n54mCLxp7slI7trLhprz0wTrwcunDjosQjE0AtyuPBS4o+nzM81CD5XGSeVkjyDblebgA==
67356730

6736-
react-navigation-tabs@1.0.1, react-navigation-tabs@^1.0.0:
6731+
react-navigation-tabs@^1.0.0:
67376732
version "1.0.1"
67386733
resolved "https://registry.yarnpkg.com/react-navigation-tabs/-/react-navigation-tabs-1.0.1.tgz#c6974e6c279687d3d7f10349b6820dccef1fd37a"
67396734
integrity sha512-XDftTg0sxh2ZMA4yJ4g8POCSova1gJM3heIUUup7/mDeUKcQRZzE9Xf9gQrbZteybJLAxATy+LAjaUpDvvdKmg==
@@ -6753,17 +6748,6 @@ react-navigation-types-only@bySabi/react-navigation#patch-1:
67536748
react-navigation-stack "^1.0.1"
67546749
react-navigation-tabs "^1.0.0"
67556750

6756-
react-navigation@^3.0.4:
6757-
version "3.0.4"
6758-
resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-3.0.4.tgz#2e2cf5bde077f9427b11223014ca604c0528758c"
6759-
integrity sha512-qVOOy2ek7ymhgZYrPeB2G8lzFb+Nn6wjGKKYEWuWO6O789K4B1KNGzSQiFrdJ73pKF+U13kJCY8lLyx/ApeWzw==
6760-
dependencies:
6761-
"@react-navigation/core" "3.0.0"
6762-
"@react-navigation/native" "3.0.2"
6763-
react-navigation-drawer "1.0.4"
6764-
react-navigation-stack "1.0.4"
6765-
react-navigation-tabs "1.0.1"
6766-
67676751
react-proxy@^1.1.7:
67686752
version "1.1.8"
67696753
resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-1.1.8.tgz#9dbfd9d927528c3aa9f444e4558c37830ab8c26a"

0 commit comments

Comments
 (0)