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.
Steps to reproduce the behavior:
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
Jest works without find utility.
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',
')'
],
馃帳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
Hey @SimenB can I take this issue?
For sure, go for it! 馃檪