Summary
@cloudflare/vitest-pool-workers is adding a new adminSecretsStore() export to cloudflare:test (cloudflare/workers-sdk#13073). This gives tests write access to secrets store bindings, which are otherwise read-only (.get() only).
Usage
import { adminSecretsStore } from "cloudflare:test";
import { env } from "cloudflare:workers";
const admin = adminSecretsStore(env.MY_SECRET);
await admin.create("test-value");
const value = await env.MY_SECRET.get(); // "test-value"
Admin API methods
create(value: string): Promise<string> — create a secret, returns its ID
update(value: string, id: string): Promise<string> — update a secret by ID
duplicate(id: string, newName: string): Promise<string> — duplicate a secret under a new name
delete(id: string): Promise<void> — delete a secret by ID
list(): Promise<{ name: string; metadata?: { uuid: string } }[]> — list all secrets
get(id: string): Promise<string> — get a secret's name by ID
Where to document
This should be added to the vitest-pool-workers testing documentation, likely alongside the existing applyD1Migrations() documentation as another binding-seeding helper.
Summary
@cloudflare/vitest-pool-workersis adding a newadminSecretsStore()export tocloudflare:test(cloudflare/workers-sdk#13073). This gives tests write access to secrets store bindings, which are otherwise read-only (.get()only).Usage
Admin API methods
create(value: string): Promise<string>— create a secret, returns its IDupdate(value: string, id: string): Promise<string>— update a secret by IDduplicate(id: string, newName: string): Promise<string>— duplicate a secret under a new namedelete(id: string): Promise<void>— delete a secret by IDlist(): Promise<{ name: string; metadata?: { uuid: string } }[]>— list all secretsget(id: string): Promise<string>— get a secret's name by IDWhere to document
This should be added to the vitest-pool-workers testing documentation, likely alongside the existing
applyD1Migrations()documentation as another binding-seeding helper.