Did I run create-react-app correctly to test? - testing

I'm trying create-react-app for testing but can't get it to work.
npx create-react-app tester
cd tester
yarn
yarn test
OUTPUT:
yarn run v1.13.0
$ react-scripts test
Done in 0.59s.
terry#terry-sharewalker:~/myProjects/tester$
I thought I read that CRA starts in "watch mode", but it just jumps back to my cursor. Isn't is supposed to run something? I see a test in the src/ folder called App.test.js. But is it running? How can I test that the test is running?
EDIT -- HERE'S MY ENVIRONMENT INFO:
npx create-react-app testing --info
npx: installed 63 in 11.717s
Environment Info:
System:
OS: Linux 4.15 Ubuntu 16.04.5 LTS (Xenial Xerus)
CPU: x64 Intel(R) Core(TM) i5-4210M CPU # 2.60GHz
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.13.0 - ~/.nvm/versions/node/v10.15.3/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/bin/npm
Browsers:
Chrome: 68.0.3440.106
Firefox: 64.0
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found

There's currently a bug with CRA's tests on new versions of node.
Try using the "LTS" (long term support) version of Node:
nodejs.org (choose LTS)
nvm: $ nvm use --lts.
Then run $ yarn again, followed by $ yarn test.
The issue seems to be with jest specifically. The updated version is fixed, but CRA is still in the process of updating it.

After days of struggling with this I updated a whole slew of things on my system. node, npm, yarn, mocha, and all the packages installed globally with both npm and brew. This fixed it.

Related

Properly set-up react-native on Mac with M1 (can't find the right answer)

I have a MacBook Pro M1 and I am trying to start a React Native project with PyCharm/WebStorm but running in the following issue:
info Installing required CocoaPods dependencies
✔ CocoaPods (https://cocoapods.org/) is not installed. CocoaPods is necessary for the iOS project to run correctly. Do you want to install it? › Yes, with gem (may require sudo)
error
/Users/nicolamacchitella/PycharmProjects/reactproject/node_modules/metro-hermes-compiler/src/emhermesc.js:77
throw ex;
^
RuntimeError: abort(Error: An error occured while trying to install CocoaPods, which is required by this template.
Please try again manually: sudo gem install cocoapods.
CocoaPods documentation: https://cocoapods.org/). Build with -s ASSERTIONS=1 for more info.
at process.abort (/Users/nicolamacchitella/PycharmProjects/reactproject/node_modules/metro-hermes-compiler/src/emhermesc.js:440:13)
at process.emit (node:events:390:28)
at emit (node:internal/process/promises:136:22)
at processPromiseRejections (node:internal/process/promises:242:25)
at processTicksAndRejections (node:internal/process/task_queues:97:32)
Node.js v17.0.1
Done
I also running some issues at first while to setup the development environment on my M1 Macbook Pro.
Try to run:
sudo gem install cocoapods
If it doesn't work, install Homebrew, and run:
brew install cocoapods

WrongPackageManagerError during the installation of PWA Studio

I try to use yarn install (node -e 'process.env.CI||process.exit(1)' || npx npm-is yarn) on https://github.com/magento/pwa-studio.git but then I get an error:
/Users/name/.npm/_npx/eb07260b9bcce2ea/node_modules/npm-is/npm-is.js:67
throw new WrongPackageManagerError(allowed, invoked);
WrongPackageManagerError: This project can only be used with the "yarn" package manager, but it was invoked by "/usr/local/lib/node_modules/npm/bin/npx-cli.js", which is not supported.
When I tried it the first time, I was informed that I have to install npm-is before continuing the installation. I installed node and yarn via Homebrew.
Operatingsystem: macOS Catalina 10.15.4,
node: v15.2.1,
yarn: v1.22.10,
npm: 7.0.10.
I don't know to fix the error. I have tried to reinstall node and yarn but it didn't help.
This currently happens with node v15 and up.
Install NMP n to select Node v14 for PWA Studio.
npm install -g n
sudo n v14
yarn install
You can try removing this line https://prnt.sc/w3cjpt from package.json:
"preinstall": "node -e 'process.env.CI||process.exit(1)' || npx npm-is yarn",

react-native eject error Unrecognized command "eject"

I'm trying to eject my app to generate Android folder. I knew it worked before, but when I type react-native eject in my React Native project's root directory I'm getting:
can-mbp:MyApp can$ react-native eject
warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn Package "bugsnag-react-native" is using deprecated "rnpm" config that will stop working from next release. Please notify its maintainers about it.
warn Package "react-native-onesignal" is using deprecated "rnpm" config that will stop working from next release. Please notify its maintainers about it.
warn Package react-native-onesignal has been ignored because it contains invalid configuration. Reason: Unknown option dependency.platforms.ios.sourceDir with value ""./ios"" was found. This is either a typing error or a user mistake. Fixing it will remove this message.
error Unrecognized command "eject".
info Run "react-native --help" to see a list of all available commands.
I've searched for it but every answer points out to that react-native eject is simply the correct form and I couldn't find anything regarding that it doesn't work.
Here is my system info from react-native info command:
System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU # 3.10GHz
Memory: 62.21 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.4.0 - /usr/local/bin/node
Yarn: 1.17.0 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.0-rc.2 => 0.60.0-rc.2
What am I doing wrong?
Since create-react-native-app is deprecated this functionality is no longer needed.
Due to this pr it's gone!
Personaly I don't like it but run npx react-native init YourProjectName and copy over what's necessary.
Update :
I copied to removed code and made a small package : https://www.npmjs.com/package/react-native-eject
Always working for me, first install in your project
yarn add react-native-eject
and then run
react-native eject
make sure you have install yarn in your pc
Type the following command
npx react-native eject

"appium &" won't start appium server in mac

I have downloaded all the required tools and able to set up environment variable.
macOS mojave : version 10.14.3
I have install node, appium and wd:
brew install node
npm install -g appium
npm install wd
when i try yo start appium server using appium & I got following error;
[1] 49460
-bash: appium: command not found
[1]+ Exit 127 appium
Updated:
None of app opens which is installed using npm command. The app installed using npm shows command not found error
It was working fine in macOs Mojave 10.14.2
Logs while using npm install -g appium
$npm install -g appium
npm WARN deprecated fsevents#2.0.1: Not Ready For Production
/Users/infotmt/bin/appium -> /Users/infotmt/lib/node_modules/appium/build/lib/main.js
> appium-chromedriver#4.9.0 install /Users/infotmt/lib/node_modules/appium/node_modules/appium-chromedriver
> node install-npm.js
[18:22:48] [Chromedriver Install] Installing Chromedriver version '2.44' for platform 'mac' and architecture '64'
[18:22:48] [Chromedriver Install] Opening temp file to write 'chromedriver_mac64' to...
[18:22:48] [Chromedriver Install] Opened temp file '/var/folders/ng/_2f_j78n1vg4gf8xnxvx9c780000gn/T/2019025-62054-1018qcf.8dtn/chromedriver_mac64.zip'
[18:22:48] [Chromedriver Install] Downloading https://chromedriver.storage.googleapis.com/2.44/chromedriver_mac64.zip...
[18:22:52] [Chromedriver Install] Writing binary content to /var/folders/ng/_2f_j78n1vg4gf8xnxvx9c780000gn/T/2019025-62054-1018qcf.8dtn/chromedriver_mac64.zip...
[18:22:52] [Chromedriver Install] Extracting /var/folders/ng/_2f_j78n1vg4gf8xnxvx9c780000gn/T/2019025-62054-1018qcf.8dtn/chromedriver_mac64.zip to /var/folders/ng/_2f_j78n1vg4gf8xnxvx9c780000gn/T/2019025-62054-1018qcf.8dtn/chromedriver_mac64
[18:22:52] [Chromedriver Install] Creating /Users/infotmt/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac...
[18:22:52] [Chromedriver Install] Copying unzipped binary, reading from /var/folders/ng/_2f_j78n1vg4gf8xnxvx9c780000gn/T/2019025-62054-1018qcf.8dtn/chromedriver_mac64/chromedriver...
[18:22:52] [Chromedriver Install] Writing to /Users/infotmt/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver...
[18:22:52] [Chromedriver Install] /Users/infotmt/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver successfully put in place
> appium-selendroid-driver#1.13.2 install /Users/infotmt/lib/node_modules/appium/node_modules/appium-selendroid-driver
> node ./bin/install.js
[18:22:54] Java version 1.8.0_202 found
[18:22:55] Ensuring /Users/infotmt/lib/node_modules/appium/node_modules/appium-selendroid-driver/selendroid/download exists
[18:22:55] Downloading Selendroid standalone server version 0.17.0 from https://repo1.maven.org/maven2/io/selendroid/selendroid-standalone/0.17.0/selendroid-standalone-0.17.0-with-dependencies.jar --> /Users/infotmt/lib/node_modules/appium/node_modules/appium-selendroid-driver/selendroid/download/selendroid-server-7cf7163ac47f1c46eff95b62f78b58c1dabdec534acc6632da3784739f6e9d82.jar
[18:23:07] Writing binary content to /Users/infotmt/lib/node_modules/appium/node_modules/appium-selendroid-driver/selendroid/download/selendroid-server.jar.tmp
[18:23:07] Selendroid standalone server downloaded
[18:23:07] Determining AndroidManifest location
[18:23:07] Determining server apk location
[18:23:07] Extracting manifest and apk to /Users/infotmt/lib/node_modules/appium/node_modules/appium-selendroid-driver/selendroid/download
[18:23:07] Copying manifest and apk to /Users/infotmt/lib/node_modules/appium/node_modules/appium-selendroid-driver/selendroid
[18:23:07] Cleaning up temp files
[18:23:07] Fixing AndroidManifest icon bug
> appium-windows-driver#1.5.1 install /Users/infotmt/lib/node_modules/appium/node_modules/appium-windows-driver
> node install-npm.js
Not installing WinAppDriver since did not detect a Windows system
> fsevents#2.0.1 install /Users/infotmt/lib/node_modules/appium/node_modules/fsevents
> [ -f fsevents.node ] || npm run prepare
> heapdump#0.3.12 install /Users/infotmt/lib/node_modules/appium/node_modules/heapdump
> node-gyp rebuild
CXX(target) Release/obj.target/addon/src/heapdump.o
In file included from ../src/heapdump.cc:17:
../../nan/nan.h:1064:44: warning: 'ToString' is deprecated: Use maybe version
[-Wdeprecated-declarations]
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
^
/Users/infotmt/.node-gyp/11.7.0/include/node/v8.h:2537:3: note: 'ToString' has
been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version",
^
/Users/infotmt/.node-gyp/11.7.0/include/node/v8config.h:326:29: note: expanded
from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated(message)))
^
1 warning generated.
SOLINK_MODULE(target) Release/addon.node
+ appium#1.10.1
added 493 packages from 406 contributors and updated 2 packages in 34.024s
My advice is as follows:
1. Do not use Homebrew to install Node.js.
The best way to do this is to use the nvm version manager. I had many conflicts with Node.js on MacOS, but nvm is a bulletproof solution.
https://yoember.com/nodejs/the-best-way-to-install-node-js/
2. It is also highly recommended to use version managers for
Ruby https://github.com/rbenv/rbenv
Python https://github.com/pyenv/pyenv
Java http://www.jenv.be/
Version managers take over Node/Ruby/Python/Java management from the system and allow you to install parallel versions and keep consistency of modules/packages/gems etc.
3. Then install the following packages:
npm install -g appium
npm install -g appium-doctor
After that you can check the list of all Appium dependencies:
appium-doctor --ios
appium-doctor --android
Follow the instructions and complete the list.
4. Never install modules/packages/gems... with sudo.
The problem is that i installed the node/npm in very old version of mac. Then i upgraded the mac version to mojave.
I solve the issue by factory resetting the mac and then updating it to latest version. After that i install node/npm and then appium. It works fine now.
Are you able to start appium server using desktop client?
https://github.com/appium/appium-desktop/releases/tag/v1.10.0
Also did you refer this https://github.com/appium/appium/issues/6738?
Check your $PATH environment variable for existence of /Users/infotmt/bin.
Try installing the desktop version from releases: https://github.com/appium/appium-desktop
Did you try to install appium-doctor?
Try running npm install -g appium-doctor as kubano tolds you. I'm currently using it in mojave, so feel free to ask me anything
try installing appium using brew brew install appium it will install the appium server on local under user
Thanks!

React Native - run-ios - React Packager process fails due to thinking I am running io.js version 1.6.2

I am attempting to start developing my first ever React Native application. I've installed the react-native-cli and ran the command react-native ios-run. The build is successful, and the simulator seems to boot up fine. However, a second terminal appears with the following message:
You are currently running io.js v1.6.2.
React Native runs on Node 4.0 or newer. There are several ways to
upgrade Node.js depending on your preference.
nvm: nvm install node && nvm alias default node
Homebrew: brew unlink iojs; brew install node
Installer: download the Mac .pkg from https://nodejs.org/
About Node.js: https://nodejs.org Follow along at: https://github.com/facebook/react-native/issues/2545
~
Process terminated. Press to close the window
I have tried:
uninstalling and reinstalling node via Homebrew.
node -v = 7.3.0
brew unlink iojs
Error: No such keg: /usr/local/Cellar/iojs
nvm install node && nvm alias default node
doesn't change anything.
navigated to /usr/local/bin and uninstalled iojs
iojs -v
-bash: iojs: command not found
brew update: no changes to formulae
brew doctor: nothing besides usual warnings
brew prune: nothing
brew cask uninstall iojs
Error: iojs is not installed
Help is appreciated here. I am at a loss to understand how I can be running io.js v1.6.2 when I'm pretty certain iojs is not installed on my machine. But perhaps I am missing something...cheers.
Finally got it. Uninstalled all versions of node / deleted any node or node_modules folders from /usr/local/lib/.
Also nvm uninstall iojs --force.
Downloaded node from https://nodejs.org/en/download/​. After all that, it worked. I'll leave this here for anyone else who encounters this problem!