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?

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?