I have been developing a sample mobile application from React native and I keep getting the following error but I cannot seems to put my finger on what's wrong there. The line does not show any errors and the details in the log do not indicate anything that I should be concern about either. But I keep getting this error.
ReferenceError: Can't find variable: useState
This error is located at:
in App (created by ExpoRoot)
in ExpoRoot (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in DevAppContainer (at AppContainer.js:121)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue
My App.js looks as follows
import "react-native-gesture-handler";
import { NavigationContainer } from "#react-navigation/native";
import { createStackNavigator } from "#react-navigation/stack";
import * as Font from "expo-font";
import AppLoading from "expo-app-loading";
import React, { useState } from "react";
import useFonts from "./hooks/useFonts";
import TravelPartner from "./src/components/mainPage";
const App = () => {
const [IsReady, SetIsReady] = useState(false);
const LoadFonts = async () => {
await useFonts();
};
if (!IsReady) {
return (
<AppLoading
startAsync={LoadFonts}
onFinish={() => SetIsReady(true)}
onError={() => {}}
/>
);
}
return (
<View styles={styles.container}>
{<Text>test run for the application</Text>}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
export default App;
All the libraries have been installed and everything Is up to date. useFonts.js looks as follows
import * as Font from "expo-font";
export default useFonts = async () => {
await Font.loadAsync({
"OtomanopeeOne-Regular": require("../src/assets/fonts/OtomanopeeOne-Regular.ttf"),
"VeganStylePersonalUse-5Y58": require("../src/assets/fonts/VeganStylePersonalUse-5Y58.ttf"),
"Festive-Regular": require("../src/assets/fonts/Festive-Regular.ttf"),
"Pacifico-Regular": require("../src/assets/fonts/Pacifico-Regular.ttf"),
});
};
This is my package.json:
{
"main": "index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start"
},
"dependencies": {
"#react-navigation/native": "^6.0.1",
"#react-navigation/stack": "^6.0.1",
"expo": "~42.0.1",
"expo-app-loading": "^1.1.2",
"expo-font": "~9.2.1",
"expo-splash-screen": "~0.11.2",
"expo-status-bar": "~1.0.4",
"expo-updates": "~0.8.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "~0.63.4",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "~1.10.2",
"react-native-reanimated": "~2.2.0",
"react-native-screens": "~3.4.0",
"react-native-unimodules": "~0.14.5",
"react-native-web": "~0.13.12"
},
"devDependencies": {
"#babel/core": "^7.9.0"
},
"private": true
}
The problem is in your React version. You are using "react": "16.13.1" but hooks are introduced in 16.8 version. Update your React version will solve the problem.
Please run:
npm install react#latest react-dom#latest
try to remove node_modules directory and package-lock.json and then run npm install
Related
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of App.
This error is located at:
in App (created by withDevTools(App))
in withDevTools(App)
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in main(RootComponent)
App.js
import { View, Text } from 'react-native'
import React, { useState } from 'react';
import { NavigationContainer } from '#react-navigation/native';
import { createNativeStackNavigator } from '#react-navigation/native-stack';
import HomeScreen from './pages/HomeScreen';
import { Font, AppLoading } from 'expo';
const Stack = createNativeStackNavigator();
const loadFonts = async () => {
return Font.loadAsync({
"open-sans": require("./assets/fonts/OpenSans-Regular.ttf"),
"open-sans-bold": require("./assets/fonts/OpenSans-Bold.ttf")
});
};
function App() {
const [fontLoaded, setFontLoaded] = useState(false);
if (!fontLoaded) {
return (
<AppLoading
startAsync={loadFonts}
onFinish={() => setFontLoaded(true)}
/>
);
}
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen}/>
</Stack.Navigator>
</NavigationContainer>
)
}
export default App;
HomeScreen
import { View, Text, SafeAreaView, StatusBar } from 'react-native'
import React from 'react';
import Header from './../components/Header';
import { Colors } from '../Values';
function HomeScreen() {
return (
<SafeAreaView style={{flex: 1, backgroundColor: Colors.bg}}>
<StatusBar backgroundColor={Colors.bg} barStyle={'dark-content'}/>
<Header/>
</SafeAreaView>
)
}
export default HomeScreen;
package.json
{
"name": "myapp",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#expo/vector-icons": "^13.0.0",
"#react-navigation/drawer": "^6.5.7",
"#react-navigation/native": "^6.1.2",
"#react-navigation/native-stack": "^6.9.8",
"expo": "~47.0.12",
"expo-status-bar": "~1.4.2",
"native-base": "2.13.8",
"react": "18.1.0",
"react-native-safe-area-context": "4.4.1",
"react-native-screens": "~3.18.0"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
I am solving error but not solve.
Solve my question
I am trying to get a simple example of tab navigation to work in react native. It seems like examples online all assume that a tab navigation screen is the one and only screen in your app, which is not the case for me. In my app I will have a login page, and upon successful login there will be a tab navigation screen I call DashboardTabScreen. The app will have other (non tab) screens available (like Settings or Contact us, or whatever) and each of the tab screens will be the root of a stack of other "detail" screens.
So here is my App.js:
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import LoginScreen from "./src/screens/LoginScreen";
import DashboardTabScreen from "./src/screens/DashboardTabScreen";
const navigator = createStackNavigator(
{
Login: LoginScreen,
DashboardTab: DashboardTabScreen
},
{
initialRouteName: "Login",
defaultNavigationOptions: {
title: "App"
}
}
);
export default createAppContainer(navigator);
And here is my DashboardTabScreen.js
import React, {Component} from "react";
import { Text, StyleSheet, View } from "react-native";
import { createBottomTabNavigator } from 'react-navigation-tabs';
const FirstScreen = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>First!</Text>
</View>
);
}
const SecondScreen = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Second!</Text>
</View>
);
}
const DashboardTabScreen = createBottomTabNavigator(
{
First: {
screen: FirstScreen,
},
Second: {
screen: SecondScreen,
}
}
);
export default DashboardTabScreen;
When I run the app, it goes to the Login screen as expected. Upon successful login, it should go to this dashboard tab screen. Instead it throws an error:
Invariant violation: Element type is invalid: expected a string (for built-in components) or
a class/function (for composite components) but got undefined. You likely forgot to export
your component from the file it is defined in, or you might have mixed up default and named
imports.
And here is my package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/bottom-tabs": "^5.4.1",
"#react-navigation/core": "react-navigation/core",
"#react-navigation/native": "^5.2.6",
"#react-navigation/stack": "5.2.3",
"expo": "~36.0.0",
"n": "^6.5.1",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-gesture-handler": "^1.6.1",
"react-native-reanimated": "^1.8.0",
"react-native-safe-area-context": "^0.6.4",
"react-native-screens": "^2.7.0",
"react-navigation": "^4.3.9",
"react-navigation-stack": "^2.0.16",
"react-navigation-tabs": "^1.2.0",
"stable": "^0.1.8"
},
"devDependencies": {
"#babel/core": "^7.0.0",
"babel-preset-expo": "~8.0.0"
},
"private": true
}
So what is wrong with my code?
I had tried your code it's working perfectly, there is no error in your code:
I think the problem is with react-navigation-tabs version:
change :
"react-navigation-tabs": "^1.2.0",
to
"react-navigation-tabs": "^2.8.7"
Hope this helps!
The problem is with the react-navigation-tabs try to upgrade and then check it.
I have a problem when I try to add a bottomnavigation in my app on the main screen:
This is the main screen code:
// Main.js
import React from 'react';
import { View, Text, StyleSheet, Button } from 'react-native';
import firebase from 'react-native-firebase';
import { NavigationContainer } from '#react-navigation/native';
import { createBottomTabNavigator } from '#react-navigation/bottom-tabs';
export default class Main extends React.Component {
state = { currentUser: null }
componentDidMount() {
const { currentUser } = firebase.auth()
this.setState({ currentUser })
}
render() {
const { currentUser } = this.state
return (
<View style={styles.container}>
<Text>
Hi {currentUser && currentUser.email}!
</Text>
</View>
)
}
}
const bottomTabNavigator = createBottomTabNavigator(
{
Main: Main,
},
{
initialRouteName: 'Main'
}
);
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}
})
No when I run it I get this error:
Error: Creating a navigator doesn't take an argument. Maybe you are trying to use React Navigation 4 API with React Navigation 5? See https://reactnavigation.org/docs/en/hello-react-navigation.html for usage guide.
<unknown>
index.bundle?platform=ios&dev=true&minify=false:109707:24
<global>
Main.js:24
loadModuleImplementation
require.js:322:6
guardedLoadModule
require.js:201:45
runUpdatedModule
require.js:657:17
metroHotUpdateModule
require.js:533:8
define
require.js:53:24
global code
Main.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:1:4
<unknown>
[native code]:0
inject
injectUpdate.js:62:35
forEach
[native code]:0
injectUpdate
injectUpdate.js:71:26
on$argument_1
HMRClient.js:40:21
emit
index.js:202:37
_ws.onmessage
WebSocketHMRClient.js:72:20
EventTarget.prototype.dispatchEvent
event-target-shim.js:818:39
_eventEmitter.addListener$argument_1
WebSocket.js:232:27
emit
EventEmitter.js:190:12
callFunctionReturnFlushedQueue
[native code]:0
So i checked my package file which is:
{
"name": "kowop",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.6",
"#react-navigation/bottom-tabs": "^5.0.3",
"#react-navigation/material-bottom-tabs": "^5.0.1",
"#react-navigation/native": "^5.0.1",
"email-validator": "^2.0.4",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-firebase": "^5.6.0",
"react-native-gesture-handler": "^1.5.6",
"react-native-paper": "^3.6.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.6.4",
"react-native-screens": "^2.0.0-beta.2",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^4.1.1",
"react-navigation-stack": "^2.0.16",
"typescript": "^3.7.5"
},
"devDependencies": {
"#babel/core": "7.8.3",
"#babel/runtime": "7.8.3",
"#react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "^6.8.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.56.4",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
But apparently react-navigation can't be updated above 4.11 or at least that is what the npm page says.
244,663
Version
4.1.1
License
MIT
Unpacked Size
41 kB
Total Files
12
Issues
133
Pull Requests
3
So I am a bit lost here. Does anyone see what I do wrong?
Thanks a lot!
Tim
You are using react-navigation v5 dependencies but in your code you implement with v4 api way.
You should change react-navigation dependencies to v4 to make your code work.
I made you code work on snack : demo
I am trying to build a navigation where I have a problem when I add
{
initialRouteName: 'Loading',
}
When I use the stacknavigator without initialRouteName everything works fine. I am working on ios simulation (react-native run-ios) and I tried pod install already a few times.
This is app.js
import React from 'react';
import Loading from './Loading';
import SignUp from './SignUp';
import Login from './Login';
import Main from './Main';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
const AppNavigator = createStackNavigator(
{
Home: Loading,
Home: SignUp,
Home: Login,
Home: Main,
},
{
initialRouteName: 'Loading',
}
);
export default createAppContainer(AppNavigator);
This is the error:
TypeError: undefined is not an object (evaluating 'routeConfigs[initialRouteName].params')
This error is located at:
in NavigationContainer (at renderApplication.js:40)
in RCTView (at AppContainer.js:101)
in RCTView (at AppContainer.js:119)
in AppContainer (at renderApplication.js:39)
getInitialState
StackRouter.js:1:2241
getStateForAction
StackRouter.js:1:4880
NavigationContainer
index.bundle?platform=ios&dev=true&minify=false:99867:102
renderRoot
[native code]:0
runRootCallback
[native code]:0
unstable_runWithPriority
scheduler.development.js:643:23
failedRoots.forEach$argument_0
react-refresh-runtime.development.js:201:29
forEach
[native code]:0
failedRoots.forEach$argument_0
react-refresh-runtime.development.js:193:24
Refresh.performReactRefresh
setUpReactRefresh.js:43:6
setTimeout$argument_0
require.js:609:10
_callTimer
JSTimers.js:146:14
callTimers
JSTimers.js:399:17
callFunctionReturnFlushedQueue
[native code]:0
Here is my package.json
{
"name": "kowop",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.6",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-gesture-handler": "^1.5.3",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.6.4",
"react-native-screens": "^2.0.0-alpha.32",
"react-navigation": "^4.1.0",
"react-navigation-stack": "^2.0.16"
},
"devDependencies": {
"#babel/core": "7.8.3",
"#babel/runtime": "7.8.3",
"#react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "6.8.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.56.4",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
Does anyone have an idea what the problem may be?
Thanks a lot!
Tim
As I know, initialroutename is using by indexed name, not screen name. In your project, you have to use 'Home'.
So you have to use different name between screens. like,
const AppNavigator = createStackNavigator(
{
loading: Loading,
signUp: SignUp,
login: Login,
main: Main,
},
{
initialRouteName: 'loading',
}
);
Aside, I think use name 'Home' for four screen is very bad idea. You have to try use different name between screens.
Change this :
{
initialRouteName: 'Loading',
}
To :
{
initialRouteName: 'Home',
}
Screen key should be passed to initialRouteName as param
Thanks, I was indeed not referring to the screen.
I'm trying to set up Enzyme testing for my React Native project. I've been getting various errors in various scenarios.
Scenario 1
When I try to set up a test for one of my components, I get this error:
/Users/TuzMacbookPro2017/Development/QMG-local/APPS/ELECTRO/node_modules/#expo/vector-icons/Zocial.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import glyphMap from './vendor/react-native-vector-icons/glyphmaps/Zocial.json';
^^^^^^^^
SyntaxError: Unexpected identifier
Some relevant files
test file
import React from "react";
import renderer from "react-test-renderer";
import { mount, ReactWrapper } from "enzyme";
import LoginView from "../src/screens/LoginView";
describe("LoginView", () => {
const wrapper = mount(<LoginView />);
it("can get through the damn test file", () => {
expect(true).toBe(true);
});
});
jest.config.js
module.exports = {
setupFilesAfterEnv: ["<rootDir>setup-tests.js"],
transformIgnorePatterns: [
"node_modules/(?!(jest-)?react-native|#react-native-community|react-native-elements)"
],
preset: "react-native"
};
babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ["babel-preset-expo"]
};
};
package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll --bail",
"testff": "node ./node_modules/jest/bin/jest.js --watchAll --bail"
},
"jest": {
"preset": "jest-expo",
"testEnvironment": "node",
"globals": {
"__DEV__": true
}
},
"dependencies": {
"#expo/samples": "2.1.1",
"#react-native-community/async-storage": "^1.3.4",
"axios": "^0.18.0",
"expo": "^32.0.0",
"flow-bin": "^0.98.1",
"native-base": "^2.12.1",
"pluralize": "^7.0.0",
"react": "16.5.0",
"react-dom": "^16.8.6",
"react-native": "0.57",
"react-native-elements": "^1.1.0",
"react-native-geocoding": "^0.3.0",
"react-native-global-font": "^1.0.2",
"react-native-indicators": "^0.13.0",
"react-native-keyboard-aware-scrollview": "^2.0.0",
"react-native-material-dropdown": "^0.11.1",
"react-native-render-html": "^4.1.2",
"react-native-uuid": "^1.4.9",
"react-navigation": "^3.9.1",
"react-redux": "^6.0.1",
"redux": "^4.0.1",
"redux-saga": "^1.0.2",
"redux-test-utils": "^0.3.0",
"redux-thunk": "^2.3.0",
"sugar": "^2.0.6"
},
"devDependencies": {
"#babel/core": "^7.4.5",
"#babel/polyfill": "^7.4.4",
"#babel/preset-env": "^7.4.5",
"#babel/preset-react": "^7.0.0",
"axios-mock-adapter": "^1.16.0",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-preset-expo": "^5.0.0",
"babel-preset-react-native": "^4.0.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.12.1",
"fetch-mock": "^7.3.3",
"jest": "^24.8.0",
"jest-enzyme": "^7.0.2",
"jest-expo": "^32.0.0",
"jsdom": "^14.1.0",
"mock-async-storage": "^2.1.0",
"prettier-eslint": "^8.8.2",
"react-test-renderer": "^16.8.6",
"redux-mock-store": "^1.5.3",
"redux-saga-tester": "^1.0.460"
},
"private": true,
"rnpm": {
"assets": [
"./assets/fonts"
]
}
}
setup.tests.js
import Adapter from "enzyme-adapter-react-16";
import { configure } from "enzyme";
import jsdom from "jsdom";
import "react-native";
import "jest-enzyme";
function setUpDomEnvironment() {
const { JSDOM } = jsdom;
const dom = new JSDOM("<!doctype html><html><body></body></html>", {
url: "http://localhost/"
});
const { window } = dom;
global.window = window;
global.document = window.document;
global.navigator = {
userAgent: "node.js"
};
copyProps(window, global);
}
function copyProps(src, target) {
const props = Object.getOwnPropertyNames(src)
.filter(prop => typeof target[prop] === "undefined")
.map(prop => Object.getOwnPropertyDescriptor(src, prop));
Object.defineProperties(target, props);
}
setUpDomEnvironment();
configure({ adapter: new Adapter() });
imports from the component under test
import React, { Component } from "react";
import {
Image,
Input,
Button,
ThemeProvider,
Overlay
} from "react-native-elements";
import { View, Text, Picker } from "react-native";
import { DotIndicator } from "react-native-indicators";
import { connect } from "react-redux";
import { login, assignUser } from "../redux/actions/authActions";
import F8StyleSheet from "../components/F8StyleSheet";
import { Dropdown } from "react-native-material-dropdown";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scrollview";
import User from "../models/User";
import uuid from "react-native-uuid";
Scenario 2
So that's a problem, but then something else interesting happens. When I swap out my LoginView for a super simple component, the test runs, but brings up some new errors that cast some suspicion on my rendering setup.
SimpleView.js
import React from "react";
import { Text, View } from "react-native";
export default (SimpleView = ({ params }) => (
<View>
<Text>SimpleView</Text>
</View>
));
test
import React from "react";
import renderer from "react-test-renderer";
import { mount, ReactWrapper } from "enzyme";
import SimpleView from "./__mocks__/SimpleView";
describe("LoginView", () => {
const wrapper = mount(<SimpleView />);
it("can get through the damn test file", () => {
expect(true).toBe(true);
});
});
errors
PASS tests/LoginView.test.js (6.058s)
LoginView
✓ can get through the damn test file (4ms)
console.error node_modules/react-dom/cjs/react-dom.development.js:506
Warning: <Text /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
in Text (created by Component)
in Component (created by SimpleView)
in View (created by Component)
in Component (created by SimpleView)
in SimpleView (created by WrapperComponent)
in WrapperComponent
console.error node_modules/react-dom/cjs/react-dom.development.js:506
Warning: The tag <Text> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.
in Text (created by Component)
in Component (created by SimpleView)
in View (created by Component)
in Component (created by SimpleView)
in SimpleView (created by WrapperComponent)
in WrapperComponent
console.error node_modules/react-dom/cjs/react-dom.development.js:506
Warning: <View /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
in View (created by Component)
in Component (created by SimpleView)
in SimpleView (created by WrapperComponent)
in WrapperComponent
console.error node_modules/react-dom/cjs/react-dom.development.js:506
Warning: The tag <View> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.
in View (created by Component)
in Component (created by SimpleView)
in SimpleView (created by WrapperComponent)
in WrapperComponent
One reason for your issue could be the "preset": "react-native" line in your jest.config.js. Try changing it to "preset": "jest-expo". This is the way the expo documentation (https://docs.expo.io/versions/v35.0.0/guides/testing-with-jest/) explains how to setup jest with your project.
I encountered the same issue, and can't find a solution. So I had to mute error output:
jest --silent
ref: https://stackoverflow.com/a/49591765/4975761