events.js:288 Error: write EPIPE when executing tests with Jest - reactjs

I have a problem when setting React Testing Library into a new project, which is a project that generates common UI components for several projects. In one of the projects it is correctly setup, but when I added React Testing Library and updated dependencies in this project, I am able to run a test but not all of them.
If I do yarn test this is the result:
Test Suites: 8 passed, 8 of 33 total
Tests: 84 passed, 84 total
Snapshots: 0 total
Time: 28 sevents.js:288
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at ChildProcess.target._send (internal/child_process.js:806:20)
at ChildProcess.target.send (internal/child_process.js:677:19)
at ChildProcessWorker.send (C:\Users\user\workspace\project\node_modules\jest-worker\build\workers\ChildProcessWorker.js:291:17)
at WorkerPool.send (C:\Users\user\workspace\project\node_modules\jest-worker\build\WorkerPool.js:32:34)
at Farm._process (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:129:10)
at Farm._enqueue (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:152:10)
at Farm._push (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:159:12)
at C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:90:14
at new Promise (<anonymous>)
at Farm.doWork (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:56:12)
Emitted 'error' event on ChildProcess instance at:
at internal/child_process.js:810:39
at processTicksAndRejections (internal/process/task_queues.js:79:11) {
errno: 'EPIPE',
code: 'EPIPE',
syscall: 'write'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried doing rm -rf node_modules and then cleaning cache, and didn't work.
Any help?

It turns out that by changing some libraries in package.json the error dissapears:
Before (KO):
"babel-jest": "^24.9.0",
"jest": "^26.0.1",
After (OK):
"babel-jest": "^26.0.1",
"jest": "^25.5.4",

By doing yarn cache clean solved my problem. If you met pipe error similar like image below. I believe it is related to memory leaks.

In my case was the version of node. I had the version 15 (from Latest Features) and changed it to the stable version 14.17.3 (from LTS).
To know which version you have use node -v in a terminal.

Related

Getting nx format:write uncommitted failed without output and eslint --fix failed without output error when I do git commit

Getting nx format:write --uncommitted failed and eslint --fix failed without output error when I try to do git commit
When I try to do git commit it is showing as below
Running tasks for staged files...
.lintstagedrc.json 1 file $schema no files [SKIPPED]
{apps, libs}/**/*. {ts, tsx, js, jsx) - 1 file * eslint-fix [KILLED]
.(ts, tsx, js, jsx, json, nd, arc) 1 file nx format:write -uncommitted [SIGSEGV] Skipped because of errors from tasks. [SKIPPED]
I
✓ Reverting to original state because of errors...
✓ Cleaning up temporary files...
*nx format:write -uncommitted failed without output (SIGSEGV).
eslint --fix failed without output

Jest should only run on changed files for pre-commit hook

I have a pre-commit hook set up using jest and the --only-changed flag. However, sometimes my entire test suite will still run (800 tests!) even if I made a change in a single file.
I looked into some other jest flags like
--lastCommit Run all tests affected by file changes in
the last commit made. Behaves similarly to
`--onlyChanged`.
--findRelatedTests Find related tests for a list of source
files that were passed in as arguments.
Useful for pre-commit hook integration to
run the minimal amount of tests necessary.
--changedSince Runs tests related to the changes since the
provided branch. If the current branch has
diverged from the given branch, then only
changes made locally will be tested. Behaves
similarly to `--onlyChanged`. [string]
Yet they all have the same problem. When doing some digging, I learned that
under the hood "If the found file is a test file, Jest runs it, simple enough. If the found file is a source file, call it found-file.js, then any test files that import found-file.js and the test files that import any of the source files that themselves import found-file.js will be run."
I'm working on a project that's relatively new to me. I'm wondering if it's possible for me to get my pre-commit hook to ONLY run the edited test, not all affected tests, or if there is a way for me to track down this tree of "transitive inverse dependencies" and try to solve the problem with different imports or something.
Here is an example of some output from trying --find-related-tests
Test Suites: 2 failed, 309 passed, 311 total
Tests: 2 failed, 803 passed, 805 total
Snapshots: 308 passed, 308 total
Time: 102.366 s
Ran all test suites related to files matching /\/Users\/me\/repo\/project\/src\/modules\/dogs\/components\/spots\/SpotsSpotter.tsx/i.
> #dogsapp/project#1.0.0 test:staged
> jest --findRelatedTests --passWithNoTests "/Users/me/repo/project/src/modules/dogs/components/spots/SpotsSpotter.tsx"
ERROR: "husky:lint-staged" exited with 1.
husky - pre-commit hook exited with code 1 (error)
It's taking WAY too long when I just made a simple change in one file. Anyone know how I can track down why this is happening?
It seems like something similar was addressed here for the --watch flag: https://www.gitmemory.com/issue/facebook/jest/8276/483695303

React: max_user_watches is set to 524288, still showing ENOSPC: System limit for number of file watchers reached

I have cloned the project and trying to run it for the first time in my system (Ubuntu 18.04.3 LTS) with npm serve, but I am getting the following error:
events.js:174
throw er; // Unhandled 'error' event
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/bs-094/Dev/FPN/fpn-frontend/public'
at FSWatcher.start (internal/fs/watchers.js:165:26)
at Object.watch (fs.js:1258:11)
at createFsWatchInstance (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleDir (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:429:19)
at FSWatcher.<anonymous> (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:477:19)
at FSWatcher.<anonymous> (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:482:16)
at FSReqWrap.oncomplete (fs.js:154:5)
Emitted 'error' event at:
at FSWatcher._handleError (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/index.js:260:10)
at createFsWatchInstance (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:40:5)
at setFsWatchListener (/home/bs-094/Dev/FPN/fpn-frontend/node_modules/chokidar/lib/nodefs-handler.js:81:15)
[... lines matching original stack trace ...]
at FSReqWrap.oncomplete (fs.js:154:5)
I have looked up the solution here & here, but my /etc/sysctl.conf has already fs.inotify.max_user_watches=524288 added in its last line. I have read that 524,288 is the maximum number of files that can be watched. So I am completely clueless on how to listen to my files i.e run my project.
How can I run this?
This worked for me! First,
$ echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf
The new value can then be loaded/sourced by running:
$ sudo sysctl -p
As increasing the limit didn't work for me, I tried a different approach. I didn't add my node_modules files to the watcher.
From my experience the best fix would be to expose the watcher configuration where one could define to ignore any folders or files of their choosing, not just node_modules.

Cant start react-native at android via react-native run-android

BUILD FAILED in 3s
Cant run react-native run-android
i connect fierbase in this project
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where:
Script 'E:\react\fb (2)\fb\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 191
* What went wrong:
A problem occurred evaluating settings 'fb'.
> Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'E' with an int value of 69
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Error: Unexpected close tagLine: 31Column: 11Char: > at error (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:651:10) at strictFail (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:677:7) at closeTag (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:871:9) at SAXParser.write (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:1436:13) at new XmlDocument (E:\react\fb (2)\fb\node_modules\xmldoc\lib\xmldoc.js:261:15) at readManifest (E:\react\fb (2)\fb\node_modules\#react-native-community\cli-platform-android\build\config\readManifest.js:38:10) at Object.projectConfig (E:\react\fb (2)\fb\node_modules\#react-native-community\cli-platform-android\build\config\index.js:59:46) at Object.get project [as project] (E:\react\fb (2)\fb\node_modules\react-native\node_modules\#react-native-community\cli\build\tools\config\index.js:134:65) at E:\react\fb (2)\fb\node_modules\react-native\node_modules\#react-native-community\cli\build\commands\config\config.js:8:452 at Array.forEach (<anonymous>)
^
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

bitbake fails on "bitbake nano"

I am trying to setup bitbake and openembedded in order to cross-compile code for angstrom 2009.x on devkit8000 (a beagleboard's clone). I have followed this page but when I try
$ bitbake nano
I get
Loading cache: 100% |##############################################################################################################################################################################################| Time: 00:00:00
Loaded 1 entries from dependency cache.
ERROR: Error parsing /home/hnsl/stuff/openembedded/recipes/images/initramfs-kexecboot-image.bb: Could not inherit file classes/rootfs_${IMAGE_PKGTYPE}.bbclass | ETA: --:--:--
ERROR: Command execution failed: Exited with 1
Apparently it seems that I need to change version of Angstrom. Using
"DISTRO="angstrom-2010.x"
on stuff/build/conf/local.conf resolves this issue.

Resources