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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature Request: Support Vitest versions above 1.5 in @cloudflare/vitest-pool-workers #6071

Closed
m-shaka opened this issue Jun 17, 2024 · 5 comments
Labels
awaiting Cloudflare response Awaiting response from workers-sdk maintainer team enhancement New feature or request

Comments

@m-shaka
Copy link
Contributor

m-shaka commented Jun 17, 2024

Describe the solution

Node.js polyfill of readFileSync is not yet implemented, but Vitest@1.6.x uses readFileSync.
https://github.com/vitest-dev/vitest/blob/6b29f3ddc86060cf3265959d4ae32e90b186cb92/packages/vitest/src/runtime/execute.ts#L110

It's a barrier to supporting Vitest@1.6.x.

Is there any problem with implementing it? Can I help you?

@m-shaka m-shaka added the enhancement New feature or request label Jun 17, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jun 17, 2024
@petebacondarwin
Copy link
Contributor

@m-shaka - is this in terms of writing tests using the @cloudflare/vitest-pool-workers to write Workers tests or some other use of Vitest?

What would the behaviour be for loading files in a Worker?

@petebacondarwin petebacondarwin added the awaiting reporter response Needs clarification or followup from OP label Jun 17, 2024
@m-shaka
Copy link
Contributor Author

m-shaka commented Jun 18, 2024

Thank you for your quick response.
seems like it's required just to run Vitest with @cloudflare/vitest-pool-workers.

Here is a minimum repro. vitest run fails since readFileSync is not yet implemented.
https://codesandbox.io/p/devbox/misty-butterfly-lnhhns

I'm not sure what Vitest is doing there, probably it's about executing test files

@m-shaka
Copy link
Contributor Author

m-shaka commented Jun 18, 2024

I found cloudflare/workerd#2147

From my understanding, @cloudflare/vitest-pool-workers will work with Vitest >= 1.6 if miniflare supports experimental:nodejs_compat_v2 compatibility flag. Is that true?
(It was a misunderstanding. v2 doesn't seem to support fs yet)

After I added experimental:nodejs_compat_v2 to compatibility_flags, I got this error.
https://codesandbox.io/p/devbox/misty-butterfly-forked-mmn6v3?file=%2Fwrangler.toml

service core:user:vitest-pool-workers-runner-: No such compatibility flag: experimental:nodejs_compat_v2

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 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 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
 ❯ #assembleAndUpdateConfig node_modules/miniflare/dist/src/index.js:9161:13
 ❯ process.processTicksAndRejections node:internal/process/task_queues:95:5
 ❯ Mutex.runWith node_modules/miniflare/dist/src/index.js:3521:16
 ❯ #waitForReady node_modules/miniflare/dist/src/index.js:9218:5
 ❯ getProjectMiniflare node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1306:5
 ❯ Object.runTests node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1556:20
 ❯ Object.runTests node_modules/vitest/dist/vendor/cli-api.E07AF1Yq.js:8862:5
 ❯ async file:/project/workspace/node_modules/vitest/dist/vendor/cli-api.E07AF1Yq.js:11207:9

@penalosa
Copy link
Contributor

penalosa commented Jul 8, 2024

Thanks for reporting this! We'll follow up with the Vitest team to find a path forward here

@penalosa penalosa added bug Something that isn't working and removed enhancement New feature or request awaiting reporter response Needs clarification or followup from OP labels Jul 8, 2024
@penalosa penalosa changed the title 🚀 Feature Request: Supporting Node.js readFileSync[vitest-pool-workers] 🚀 Feature Request: Support Vitest versions above 1.5 in @cloudflare/vitest-pool-workers Jul 8, 2024
@penalosa penalosa added enhancement New feature or request and removed bug Something that isn't working labels Jul 8, 2024
@andyjessop andyjessop added the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Jul 8, 2024
@penalosa
Copy link
Contributor

penalosa commented Aug 21, 2024

Closing in favour of #6215

@penalosa penalosa closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2024
@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Cloudflare response Awaiting response from workers-sdk maintainer team enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

4 participants