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?
2 Replies
MrBBot
MrBBot•2y ago
Hey! 👋 That README is actually out-of-date, thanks for catching this. It should be updated to something like:
import { createSQLiteDB } from "@miniflare/shared";
import { D1Database, D1DatabaseAPI } from "@miniflare/d1";

const sqliteDb = await createSQLiteDB(":memory:");
const db = new D1Database(new D1DatabaseAPI(sqliteDb));
await db.prepare(...);
import { createSQLiteDB } from "@miniflare/shared";
import { D1Database, D1DatabaseAPI } from "@miniflare/d1";

const sqliteDb = await createSQLiteDB(":memory:");
const db = new D1Database(new D1DatabaseAPI(sqliteDb));
await db.prepare(...);
...but note this won't work inside the Jest environment described here, https://miniflare.dev/testing/jest, you'll need to run this code from a regular Node environment
esdee
esdeeOP•2y ago
Ah thank you - that makes sense. Idid make some progress in testing within miniflare, see here - https://discord.com/channels/595317990191398933/1092907590968692926/1093246414777233529 but I think its quite fragile.
Want results from more Discord servers?
Add your server