question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest crashes on systems without find

See original GitHub issue

🐛 Bug Report

Jest crashes on systems without find. It would be automatically detected if the utility was available and handled this gracefully.

An alternative would be to allow forceNodeFilesystemAPI parameter to be passed from https://github.com/facebook/jest/blob/9ac2dcd55c0204960285498c590c1aa7860e6aa8/packages/jest-core/src/cli/index.ts#L123 to https://github.com/facebook/jest/blob/89c151b69f81baba49caeceec19f07b4bc2680cc/packages/jest-runtime/src/index.ts#L242 which would force it to not use the find utility.

To Reproduce

Steps to reproduce the behavior:

  • Run jest on a system without find (in our case, AWS lambda node12.x runtime)

Docker image for lambda like runtime environment

docker run -it --rm -v <path_to_lambda>:/var/task:ro,delegated --entrypoint /bin/bash lambci/lambda:nodejs12.x

Expected behavior

Jest works without find utility.

Link to repl or repo (highly encouraged)

From node, try to run tests using jest-cli package

const jestCli = require("jest-cli");
jestCli.runCLI({ }, '.');

Stacktrace Jest crashes with uncaught exception trying to invoke find utility https://github.com/facebook/jest/blob/ee2bea16a9f401581a884d9faa0951b552a86fe4/packages/jest-haste-map/src/crawlers/node.ts#L102

Thrown:
Error: spawn find ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn find',
  path: 'find',
  spawnargs: [
    '/var/task', '-type',
    'f',         '(',
    '-iname',    '*.snap',
    '-o',        '-iname',
    '*.js',      '-o',
    '-iname',    '*.json',
    '-o',        '-iname',
    '*.jsx',     '-o',
    '-iname',    '*.node',
    ')'
  ],

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Feb 13, 2020

For sure, go for it! 🙂

1reaction
leonardovillelacommented, Feb 13, 2020

Hey @SimenB can I take this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Jest
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​.
Read more >
'command not found: jest' - Stack Overflow
I just ran into this issue where I had been using jest on the CLI fine until suddenly jest was an 'unknown command'....
Read more >
A Practical Guide To Testing React Applications With Jest
Jest is one of the best tools available for testing React ... checks to see whether our app component renders correctly without crashing....
Read more >
React Testing Crash Course - Emarsys Craftlab
These assertions, however, do not cover all use-cases. Those missing assertions can be imported with Jest's plugin system, adding new types ...
Read more >
Testing React Applications with Jest - Auth0
Learn how to test React applications with the Jest JavaScript testing ... import { mount } from 'enzyme'; it('renders without crashing', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found