Jest: Jest crashes on systems without find

Created on 19 Dec 2019  路  4Comments  路  Source: facebook/jest

馃悰 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',
    ')'
  ],
Bug Help Wanted good first issue

All 4 comments

馃帳Anyone out there?

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

Hey @SimenB can I take this issue?

For sure, go for it! 馃檪

Was this page helpful?
0 / 5 - 0 ratings