vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
13.15k stars 1.19k forks source link

Error: EISDIR: illegal operation on a directory, read #5494

Open aelbore opened 7 months ago

aelbore commented 7 months ago

Describe the bug

when running the test it has "Error: EISDIR: illegal operation on a directory" error. when using "happy-dom" and "jsdom" with "rxjs@6.6.7"

it works fine if

when it using playwright it works fine with using "happy-dom" and "jsdom" with "rxjs@7.x"

Reproduction

stackblitz https://stackblitz.com/edit/stackblitz-starters-yjhfgh

Just download and run it locally

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 11.09 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.19.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm
  Browsers:
    Chrome: 123.0.6312.107
    Edge: 123.0.2420.81
    Safari: 17.4.1
  npmPackages:
    vitest: ^1.4.0 => 1.4.0

Used Package Manager

npm

Validations

aelbore commented 7 months ago

https://github.com/analogjs/analog/issues/1009

roeb commented 3 months ago

I get the same error when I try to merge multiple test results with

npx vitest --merge-reports=reports --reporter=json --reporter=default

In the reports folder there are further folders with the test results. If the test results lie flat in reports, the same error occurs.

sheremet-va commented 3 months ago

I get the same error when I try to merge multiple test results with

npx vitest --merge-reports=reports --reporter=json --reporter=default

In the reports folder there are further folders with the test results. If the test results lie flat in reports, the same error occurs.

If you have an issue with merge reporter, create a separate issue. From you description, it seems that you are using it wrong. merge-reports expects a folder with a flat structure containing only reports generated by --reporter=blob.

Dan1ve commented 2 months ago

I just got this error after updating from 2.0.5 to 2.1.0. I still need to rule out a CI caching issue, but this is the stack trace:

> vitest run

 RUN  v2.1.0 /builds/app
⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯
Error: EISDIR: illegal operation on a directory, read
 ❯ readFileHandle node:internal/fs/promises:553:24
 ❯ node_modules/.pnpm/vitest@2.1.0_@types+node@22.5.4_@vitest+browser@2.1.0_@vitest+ui@2.1.0_less@4.2.0_msw@2.4.5_typescript@5.6.2_/node_modules/vitest/dist/chunks/resolveConfig.-K5hHm0S.js:4016:20
 ❯ groupFilesByEnv node_modules/.pnpm/vitest@2.1.0_@types+node@22.5.4_@vitest+browser@2.1.0_@vitest+ui@2.1.0_less@4.2.0_msw@2.4.5_typescript@5.6.2_/node_modules/vitest/dist/chunks/resolveConfig.-K5hHm0S.js:4012:24
 ❯ Object.runTests node_modules/.pnpm/vitest@2.1.0_@types+node@22.5.4_@vitest+browser@2.1.0_@vitest+ui@2.1.0_less@4.2.0_msw@2.4.5_typescript@5.6.2_/node_modules/vitest/dist/chunks/resolveConfig.-K5hHm0S.js:4256:28
 ❯ executeTests node_modules/.pnpm/vitest@2.1.0_@types+node@22.5.4_@vitest+browser@2.1.0_@vitest+ui@2.1.0_less@4.2.0_msw@2.4.5_typescript@5.6.2_/node_modules/vitest/dist/chunks/resolveConfig.-K5hHm0S.js:5134:5
 ❯ node_modules/.pnpm/vitest@2.1.0_@types+node@22.5.4_@vitest+browser@2.1.0_@vitest+ui@2.1.0_less@4.2.0_msw@2.4.5_typescript@5.6.2_/node_modules/vitest/dist/chunks/cli-api.KmLFBnKP.js:10246:9
 ❯ Vitest.runFiles node_modules/.pnpm/vitest@2.1.0_@types+node@22.5.4_@vitest+browser@2.1.0_@vitest+ui@2.1.0_less@4.2.0_msw@2.4.5_typescript@5.6.2_/node_modules/vitest/dist/chunks/cli-api.KmLFBnKP.js:10266:12
 ❯ Vitest.start node_modules/.pnpm/vitest@2.1.0_@types+node@22.5.4_@vitest+browser@2.1.0_@vitest+ui@2.1.0_less@4.2.0_msw@2.4.5_typescript@5.6.2_/node_modules/vitest/dist/chunks/cli-api.KmLFBnKP.js:10109:7
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { errno: -21, code: 'EISDIR', syscall: 'read' }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
 Test Files  no tests
      Tests  no tests
     Errors  1 error
Dan1ve commented 2 months ago

I debugged this and it seems that this line from resolveConfig.-K5hHm0S.js (from the stacktrace) causes the crash

async function groupFilesByEnv(files) {
 // ...
 const code = await promises$1.readFile(file, "utf-8");
}

It appears the passed file is actually a folder ("node_modules/better-sqlite3" in my case). This also happens if I explicitly exclude node_modules/** in vitest.config.js by the way.

Also happens with 2.1.1

hi-ogawa commented 2 months ago

@Dan1ve From the conversation on https://github.com/analogjs/analog/issues/1009, OP's issue seems specific to angular integration and some workaround is suggested there. Do you have a similar setup? If so, have you checked the workaround? If not, it's probably better to raise a new issue with a reproduction on your own so that we can investigate the issue further.

Dan1ve commented 2 months ago

Thank you for the pointer. The error happens in a SvelteKit project (so no Angular), but I can do some experiments based on the linked issue, once I find the time.

Note that everything works fine with vitest 2.0.5 though.