Cloudflare Developers

CD

Cloudflare Developers

Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news

Join

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. ``` FAIL src/impl.test.mts [ src/impl.test.mts ] Error: No such module "C:/git/vitest-wrangler-discord-api-types/node_modules/discord-api-types/v10.js". imported from "C:/git/vitest-wrangler-discord-api-types/node_modules/discord-api-types/v10.mjs"...

Is anyone able to debug vitest tests in

Is anyone able to debug vitest tests in vscode with breakpoints? My tests just pass without stopping at breakpoints. I can debug/breakpoint normal worker code (wrangler dev, attach with vscode)

Hey all, I tried to search for solutions

Hey all, I tried to search for solutions to this issue but couldn't find any. I'm running into this error with vitest-pool-workers ``` FAIL test/index.spec.ts [ test/index.spec.ts ] TypeError: Cannot use require() to import an ES Module. ❯ Users/arishi/personal/naamdeo-monorepo/node_modules/.pnpm/[email protected]/node_modules/snakecase-keys/index.js?mf_vitest_no_cjs_esm_shim:4:23...

Is there any way to reset mocks with

Is there any way to reset mocks with fetchMock? The docs say "Deactivated by default and reset before running each test file.", but I'm seeing mocks carry over between describe blocks within a single test file and it'd be useful to just reset between the describe blocks in an afterAll or afterEach.

I am trying to directly access a durable

I am trying to directly access a durable object in my tests to run the alarm, but I am unsure how to correctly add the binding to my test env without getting type errors

I ran into this issue too - `Error:

I ran into this issue too - Error: require() is not yet implemented in Workers A simple worker [with not imports] works fine. But, when inngest is imported, it fails...

👋 When using `import {

👋 When using import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';, how do you define your service bindings that normally exist in wrangler.toml? Example from wrangler.toml ``` [[services]]...

Hello! 👋 We're running into these

Hello! 👋 We're running into these errors quite a lot. ``` ================================================================================ Failed to pop isolated storage stack frame in test/room/websockets.test.ts's test "sent ops are received over WebSocket by connected clients on V7"....

Hey, does anyone know how to use `export

Hey, does anyone know how to use export default class extends WorkerEntrypoint with SELF and typescript ?

Is there a workaround that will let me

Is there a workaround that will let me test a Durable Object waking up from hibernation at all? Or is this currently impossible to test? Asking, because I'm trying to simulate that event by waiting for 10 seconds, but every time I do, I hit a segfault… 😬 I made a minimal replication in this repo (on the hibernate branch): https://github.com/nvie/ws-promise-bug-repro/blob/hibernate/durable-objects/test/illustrate-bug.test.ts#L22-L24...

Slow R2 puts

Loving this right now, ty! I am seeing weirdly slow times with R2 puts though, any idea why? It's taking ~400ms right now for small files. Currently taking up basically all of my test time :blob_sweat: I spoke with James and he had the same issue. His repro: https://github.com/Cherry/ShareX-R2-Cloudflare-Workers/blob/main/test/upload.test.ts...

Hey Cloudflare team! We're making great

Hey Cloudflare team! We're making great progress in migrating our code base from Jest to Vite and to new Vitest integration—we're almost done! There is however one remaining issue that we cannot figure out ourselves. It's really hard to explain for us what's going on here, but fortunately it can be reliably reproduced, so I've made a screencast. Maybe you could help us with this? Because currently it's blocking us from finishing our migration. The screencast/demo: 🍿 https://share.cleanshot.com/d914hhK8RFYpDP5N9Ldg ...

Would you mind opening a GitHub issue

Would you mind opening a GitHub issue for an explicit hibernation API in cloudflare:test so we can track this?

The examples you provided in https://

The examples you provided in https://github.com/cloudflare/workers-sdk/tree/main/fixtures/vitest-pool-workers-examples are really useful! I was in particular looking for a best practice example to test WebSockets. I was trying the following setup (which is roughly how it worked in Miniflare v2): ```...

Why am i not seeing my console.log

Why am i not seeing my console.log output in tests? I'm building a cloudflare worker using Hono and using vitest for testing. I have a simple test file but the second 'console.log' isn't showing. Why not? When I remove the call to "request" it does show. (p.s. createExecutionContext/waitOnExecutionContext doesn't make a difference) ```typescript...

🐛 BUG: "Module cannot be synchronously ...

Hello! 👋 I'm currently trying to migrate our test suite to Vite + the new pool workers, and I have run into this issue while doing so: https://github.com/cloudflare/workers-sdk/issues/5367 — is this a known issue? Any recommendations?

Asserting like this: `expect(res2.

Asserting like this: expect(res2.headers.get('CF-Cache-Status')).toBe('HIT') I am using waitUntil for the cache put, but awaiting it doesn't seem to work either...

sorry for all the spam, haha

sorry for all the spam, haha ``` workerd/io/worker.c++:1816: info: uncaught exception; source = Uncaught (in promise); exception = TypeError: Cannot use require() to import an ES Module. workerd/io/io-context.c++:359: info: uncaught exception; exception = workerd/jsg/_virtual_includes/jsg/workerd/jsg/value.h:1343: fa...

Fetch cannot load MY_PATH

I'm currently stuck with this error cross all integration tests:
TypeError: Fetch API cannot load: <MY_PATH>
TypeError: Fetch API cannot load: <MY_PATH>
...

Had a really strange issue where my

Had a really strange issue where my tests could no longer run due to AssertionError: Expected Vitest to start running before importing modules
No description
Next