
Research
/Security News
Toptalβs GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptalβs GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
@variablesoftware/mock-kv
Advanced tools
ποΈπ·οΈβ¨ Mock KV Namespace for testing Cloudflare Workers
Mock Cloudflare KV Namespace for unit and integration testing
ποΈπ·οΈβ¨ @variablesoftware/mock-kv
provides an in-memory simulation of Cloudflare Workers KV. It is designed for testing key-value storage logic with expiration, metadata, and batch operations β without any external dependencies.
yarn add --dev @variablesoftware/mock-kv
This package assumes a test environment with Vitest and support for ESM.
import { mockKVNamespace } from '@variablesoftware/mock-kv';
const kv = mockKVNamespace();
await kv.put('token-abc', 'value', { expirationTtl: 60 });
const result = await kv.get('token-abc');
console.log(result); // 'value'
@variablesoftware/logface
is required for test and runtime logging, but does not rely on any external servicesIncludes matching behavior for edge cases like:
Key expiration mid-test
list()
with prefix collisions and limits
Metadata preservation across put/get calls
In-memory mock of Cloudflare KVNamespace
Supports put
, get
, delete
, list
, and metadata options
TTL-aware: honors expirationTtl
and expiration
Returns values as string
, ArrayBuffer
, or null
just like real KV
Simulates listing behavior including prefix + limit
Supports metadata in put()
and getWithMetadata()
Compatible with Vitest and any Cloudflare Worker test setup
Logs via @variablesoftware/logface
Optional .dump()
method for inspecting KV state during tests
Tested using vitest run
, with coverage for:
put()
with TTL and metadataget()
and getWithMetadata()
matching real behaviordelete()
and list()
consistency.dump()
snapshots for inspection and debuggingRun tests:
yarn test
This package is under active development and not yet stable.
Once stable, it will be published as:
"@variablesoftware/mock-kv": "^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 KV Namespace for testing Cloudflare Workers
We found that @variablesoftware/mock-kv 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.
Research
/Security News
Threat actors hijacked Toptalβs GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.