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

Hi folks I m trying to run a jest test

Hi folks. I'm trying to run a jest test with miniflare on my worker / durable object. However, I get this error: ` SyntaxError: Unexpected token 'export' at VMScriptRunner.runAsModule (../../node_modules/@miniflare/runner-vm/src/index.ts:34:20) at VMScriptRunner.run (../../node_modules/@miniflare/runner-vm/src/index.ts:86:28)...

Continuing into my testing for workers

Continuing into my testing for workers, miniflare, d1 I found this repo https://www.npmjs.com/package/@miniflare/d1. However the first import import { BetaDatabase } from "@miniflare/d1"; fails with the error Module '"@miniflare/d1"' has no exported member 'BetaDatabase' - anyone seen this before?

MrBBot 4470 I m writing tests `vitest

@mrbbot I'm writing tests (vitest-environment-miniflare) for a worker that binds another worker. The other worker has a DO, and I've bound that DO to the original worker as well. I want to seed an instance of the DO for tests, but I'm running into trouble because constructing that DO requires the other worker's env (to fetch another bound worker). Is there a way to get the other env, or a different pattern I should be using to seed the DO?

I m trying to test some worker code

I'm trying to test some worker code using this guide https://miniflare.dev/testing/jest. I was able to test KV use, does anyone know what I need to add to my jest.config.js to test D1 use?

Might have asked this before but any

Might have asked this before, but any chance there will be a way to run a single function/file in a Workers environment, for unit testing, without having to mock an entire Worker just to test it?

How do I get access to environment

How do I get access to environment variables in test file?

The miniflare vitest docs have this note

The miniflare vitest docs have this note, "you must call the globalsetupMiniflareIsolatedStorage()Ā method at the start of your tests and use the returnedĀ describeĀ function in-place of the regularĀ describe/suiteĀ functions imported fromĀ vitestĀ to enable isolated storage.We're investigating ways of removing this requirement in the future, and will likely remove this function in a future release." This makes me sad. I like my describe level to be independent of other describe level things, but I use test/it level to organize a long chain of interdependent steps (create an item, update the item in one way, update the item in another way, etc.). Right now, I can just not use globalsetupMiniflareIsolatedStorage, but if you make it automatic later, it sounds like all of my tests will break. I'm hoping that there will be a way to control the isolation rather than have it always be on....

I m using miniflare with vitest and

I'm using miniflare with vitest and noticed that it doesn't inject crypto into the env that gets passed to a durable object. I have a work-around where I inject it in my test but it's boilerplate for all tests and I'm wondering if there some way to make it do this via vitest.config.ts?

if you want it to work for now you can

if you want it to work for now, you can use this patch patches/@[email protected] ```diff diff --git a/dist/src/index.js b/dist/src/index.js index cee85bc1677d6d7fd1f0027cda47d16a07b43116..1118bb81d4b66021d7fe76cb446f7a875aacd03c 100644...

Does it work fine when deployed only an

Does it work fine when deployed & only an issue with Miniflare?

hey I m using vitest for testing and

hey! I'm using vitest for testing, and "suddenly" (in quotes as I can't figure out how I broke it) I get the following error: ```TypeError: Cannot set property crypto of #<Object> which has only a getter āÆ Object.setup node_modules/vitest-environment-miniflare/src/index.ts:80:11 āÆ Module.withEnv node_modules/vitest/dist/chunk-runtime-setup.667a5719.js:888:15 886| files.map(async (fsPath) => { 887| getWorkerState().moduleCache.delete(fsPath);...

Hmmmmmmmm I have tried upgrading to 2 11

Hmmmmmmmm, I have tried upgrading to 2.11 and now get this in the logs (on all requests): [mf:err] OPTIONS /v2/staff/wsauth?rnd=14084505647541512: TypeError: Failed to parse URL from [object Object] at new Request (/home/aarhus/backend/node_modules/undici/lib/fetch/request.js:76:15) at new Request (/home/aarhus/backend/node_modules/miniflare/node_modules/@miniflare/core/src/standards/http.ts:393:13)...

Is there a way to easily change the log

Is there a way to easily change the log-level with miniflare? for some reason I can't seem to find an option to completely disable the HTTP logging

Anyone have luck with tsup esbuild for

Anyone have luck with tsup (esbuild) for building dependencies that use built-ins like Buffer? I've tried a million things to get the usage of a third party tool (passkit-generator). If I output ESM, I get: ```...

Hey šŸ‘‹ For now you ll need to define

Hey! šŸ‘‹ For now, you'll need to define your own ExecutionContext class: ```js class ExecutionContext { promises = []; waitUntil(promise) { this.promises.push(promise); }...

Udici bug

Send you a friend request to follow up in DM, but do you send multiple requests by any chance?