
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@variablesoftware/mock-d1
Advanced tools
๐๏ธ๐๏ธ๐ง Mock D1 Database implementation for testing Cloudflare Workers
Mock Cloudflare D1 Database for unit and integration testing
๐๏ธ๐๏ธ๐ง @variablesoftware/mock-d1
provides an in-memory simulation of Cloudflare's D1 SQLite-compatible database. It enables fast, isolated, and predictable testing of SQL-backed applications without relying on external services.
pnpm add --dev @variablesoftware/mock-d1
This package assumes a test environment with Vitest and support for ESM.
import { mockD1Database } from "@variablesoftware/mock-d1";
const db = mockD1Database({
sessions: [{ sub: "user-123", jti: "token-abc", created: Date.now() }],
});
const stmt = db.prepare("SELECT * FROM sessions WHERE sub = ?");
stmt.bind("user-123");
const result = await stmt.all();
console.log(result.results); // [{ sub: 'user-123', ... }]
.prepare().bind().all()
and .run()
flow@variablesoftware/logface
SELECT
, INSERT
, UPDATE
, and DELETE
statements.dump()
method for snapshot inspectionD1Result
Tested using vitest run
, with coverage for:
mockD1Database()
with randomized insert/select/delete operations to simulate real query volumeD1Result
Run tests:
pnpm test
This package is under active development and not yet stable.
Once stable, it will be published as:
"@variablesoftware/mock-d1": "^0.5.0"
MIT ยฉ Rob Friedman / Variable Software
Built with โค๏ธ by @variablesoftware
Thank you for downloading and using this project. Pull requests are warmly welcomed!
FAQs
๐๏ธ๐๏ธ๐ง Mock D1 Database implementation for testing Cloudflare Workers
The npm package @variablesoftware/mock-d1 receives a total of 142 weekly downloads. As such, @variablesoftware/mock-d1 popularity was classified as not popular.
We found that @variablesoftware/mock-d1 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.