Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest crashes on systems without find #9329

Closed
mario-see-zocdoc opened this issue Dec 19, 2019 · 5 comments 路 Fixed by #9579
Closed

Jest crashes on systems without find #9329

mario-see-zocdoc opened this issue Dec 19, 2019 · 5 comments 路 Fixed by #9579

Comments

@mario-see-zocdoc
Copy link

馃悰 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',
    ')'
  ],
@ryanblock
Copy link

馃帳Anyone out there?

@SimenB
Copy link
Member

SimenB commented Feb 13, 2020

PR welcome! Right now we skip the find call on windows, we need to check that find exists as well. I don't think exposing forceNodeFilesystemAPI is correct - jest-haste-map should be smart enough to figure it out itself.

Doing which('find') should be fine, using https://www.npmjs.com/package/which

https://github.com/facebook/jest/blob/5f817428cae42c88aac1d751239d1d937501ef93/packages/jest-haste-map/src/crawlers/node.ts#L196-L200

@leonardovillela
Copy link
Contributor

Hey @SimenB can I take this issue?

@SimenB
Copy link
Member

SimenB commented Feb 13, 2020

For sure, go for it! 馃檪

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants