Skip to content

Commit

Permalink
Fix "npm test" on Windows 10 (react-navigation#4066)
Browse files Browse the repository at this point in the history
* Fix Windows

* update prettier

* Explain need for assetsTransformer in comment
  • Loading branch information
jedmao authored and brentvatne committed Apr 27, 2018
1 parent 7ae4c60 commit 921ee09
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
4 changes: 1 addition & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
"react/forbid-prop-types": "warn",
"react/prop-types": "off",
"react/require-default-props": "off",
"react/no-unused-prop-types": "off",
},
"settings": {
"react/no-unused-prop-types": "off"
},
"parserOptions": {
"ecmaVersion": 6,
Expand Down
12 changes: 12 additions & 0 deletions assetsTransformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* This file is needed to hijack asset imports so that test files don't attempt
* to import them as JavaScript modules.
* See https://github.com/facebook/jest/issues/2663#issuecomment-317109798
*/
const path = require('path');

module.exports = {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};
15 changes: 8 additions & 7 deletions flow/react-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,14 @@ declare module 'react-navigation' {
goBack: (routeKey?: ?string) => boolean,
dismiss: () => boolean,
navigate: (
routeName: | string
| {
routeName: string,
params?: NavigationParams,
action?: NavigationNavigateAction,
key?: string,
},
routeName:
| string
| {
routeName: string,
params?: NavigationParams,
action?: NavigationNavigateAction,
key?: string,
},
params?: NavigationParams,
action?: NavigationNavigateAction
) => boolean,
Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@
"babel-preset-react-native": "^2.1.0",
"codecov": "^2.2.0",
"eslint": "^4.2.0",
"eslint-config-prettier": "^2.3.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.1.0",
"husky": "^0.14.3",
"jest": "^22.1.3",
"jest-expo": "^25.1.0",
"lint-staged": "^4.2.1",
"prettier": "^1.5.3",
"prettier-eslint": "^6.4.2",
"prettier": "^1.12.1",
"prettier-eslint": "^8.8.1",
"react": "16.2.0",
"react-native": "^0.52.0",
"react-native-vector-icons": "^4.2.0",
Expand All @@ -67,7 +67,7 @@
"jest": {
"notify": true,
"preset": "react-native",
"testRegex": "./src/.*\\-test\\.js$",
"testRegex": "/__tests__/[^/]+-test\\.js$",
"setupFiles": [
"<rootDir>/jest-setup.js"
],
Expand All @@ -82,8 +82,11 @@
"coveragePathIgnorePatterns": [
"jest-setup.js"
],
"moduleNameMapper": {
"\\.png$": "<rootDir>/assetsTransformer.js"
},
"modulePathIgnorePatterns": [
"examples"
"<rootDir>/examples/"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|react-navigation-deprecated-tab-navigator)"
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/NavigationContainer-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import 'react-native';
import { StyleSheet, View } from 'react-native';

import renderer from 'react-test-renderer';
Expand Down
4 changes: 3 additions & 1 deletion src/views/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56;

const getAppBarHeight = isLandscape => {
return Platform.OS === 'ios'
? isLandscape && !Platform.isPad ? 32 : 44
? isLandscape && !Platform.isPad
? 32
: 44
: 56;
};

Expand Down

0 comments on commit 921ee09

Please sign in to comment.