tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
906 stars 85 forks source link

File mocks suddenly started failing on GitHub Actions #305

Open dkundel opened 4 years ago

dkundel commented 4 years ago

Hey there! I have no clue if this is a mock-fs problem or a GitHub Actions problem, so I figured I'd start here.

We added a month back mock-fs to a project and it run flawlessly in GitHub Actions. You can see the successful PR here

Right now if I'm creating PRs the same validation fails even though we haven't changed anything there. See this PR as an example including some failed attempts of my trying to pin point the problem. Here's another one. In both cases it fails with the same problem:

2020-07-28T17:49:48.8122642Z FAIL __tests__/config/utils/env.test.ts
2020-07-28T17:49:48.8123762Z   ● readLocalEnvFile › should load the default env variables
2020-07-28T17:49:48.8123919Z 
2020-07-28T17:49:48.8124155Z     EAGAIN: resource temporarily unavailable, read
2020-07-28T17:49:48.8124236Z 
2020-07-28T17:49:48.8124375Z 
2020-07-28T17:49:48.8124441Z 
2020-07-28T17:49:48.8124951Z   ● readLocalEnvFile › should load env variables from a different filename
2020-07-28T17:49:48.8125164Z 
2020-07-28T17:49:48.8125322Z     EBADF: bad file descriptor, read
2020-07-28T17:49:48.8125450Z 
2020-07-28T17:49:48.8125516Z 
2020-07-28T17:49:48.8125631Z 
2020-07-28T17:49:48.8126079Z   ● readLocalEnvFile › should load the default env variables with different cwd
2020-07-28T17:49:48.8126176Z 
2020-07-28T17:49:48.8126406Z     EBADF: bad file descriptor, read
2020-07-28T17:49:48.8126557Z 
2020-07-28T17:49:48.8126625Z 
2020-07-28T17:49:48.8126690Z 
2020-07-28T17:49:48.8127127Z   ● readLocalEnvFile › should load env variables from a different filename & cwd
2020-07-28T17:49:48.8127295Z 
2020-07-28T17:49:48.8127497Z     EBADF: bad file descriptor, read
2020-07-28T17:49:48.8127571Z 
2020-07-28T17:49:48.8127686Z 
2020-07-28T17:49:48.8127752Z 
2020-07-28T17:49:48.8128229Z   ● readLocalEnvFile › should fallback to system env variables for empty variables with loadSystemEnv
2020-07-28T17:49:48.8128335Z 
2020-07-28T17:49:48.8128537Z     EBADF: bad file descriptor, read
2020-07-28T17:49:48.8128661Z 
2020-07-28T17:49:48.8128754Z 
2020-07-28T17:49:48.8128886Z 

You can find the code for the test here: https://github.com/twilio-labs/twilio-run/blob/master/__tests__/config/utils/env.test.ts

Any help would be appreciated.

3cp commented 4 years ago

There were numerous issues with jest+mock-fs. You might try the older jest version when that PR built successfully.

dkundel commented 4 years ago

I tried to pin jest to the exact version I had used before but that still doesn't seem to work. It also seems to work locally just fine.

onhernandes commented 4 years ago

Same happening here. I got the same error when trying to read a file with fs.createReadStream(), using jest 26.1.0.

3cp commented 4 years ago

@dkundel your PR passed CI. Did you do something, or it just recovered by itself?

reccanti commented 5 months ago

Also running into this issue. Was anyone able to get a fix working?