Hey folks, looking at getting into using
Hey folks, looking at getting into using vitest for testing a discord bot but having problems when it tries to import discord-api-types. Of note, i tried this without the wrangler integration and just using vitest on its own and the test is fine, its only when i configure vitest with the wrangler integration that it fails.
8 Replies
example repo to show the issue: https://github.com/davidhouweling/vitest-wrangler-discord-api-types
GitHub
GitHub - davidhouweling/vitest-wrangler-discord-api-types: Example ...
Example issue of vitest wrangler discord-api-types - davidhouweling/vitest-wrangler-discord-api-types
it is very much the same as https://discord.com/channels/595317990191398933/1218150105777963101/1218598314405007370
in the example repo, i've added in
NODE_DEBUG=vitest-pool-workers:module-fallback
environment variable and this is the output...
part 1...
part 2...
i'm using discord-api-types fine in the actual application itself, so it feels quite wrong that this is an issue just with testing.Agree. I'm struggling with this too
wrangler applies the compatibility module transformations but vitest integration does not, suggesting different module resolution for the vitest integration
raised an issue in github so that it can appropriately be tracked as it doesn't look like we are getting any traction here: https://github.com/cloudflare/workers-sdk/issues/7323
GitHub
🐛 BUG: Vitest integration does not work with discord-api-types · Is...
Which Cloudflare product(s) does this pertain to? Workers Vitest Integration What version(s) of the tool(s) are you using? 0.5.28 [@cloudflare/vitest-pool-workers] What version of Node are you usin...
Agree. I did the same.
Do you think trying to test with Miniflare 2 would be worth it? I'm evaluating that now for myself.
i actually came to the same conclusion as well, as in taking a crack at using minflare on its own and just pulling what i need in a test setup rather than trying to set up a global approach
Beware though:
Warning This repository is for Miniflare 2, which is only receiving critical security updates. Miniflare 2 simulated the Workers runtime and the rest of the Cloudflare developer platform using Node.js. New versions of Miniflare can be found in the workers-sdk repository, and use the open-sourced Workers runtime workerd. This practically eliminates behaviour mismatches between development and production deployments. We recommend you migrate to Miniflare 3 now if you can. Whilst Miniflare 3 supports most of Miniflare 2's features, one key omission is the unit testing environment. We're actively working on adding support for this to Miniflare 3. Once this is supported, we're planning to deprecate Miniflare 2 and archive this repository.
thanks. i am taking a crack at it with miniflare 3. i'll see what i come up with...