Skip to content

Document adminSecretsStore() in cloudflare:test for vitest-pool-workers #29388

@penalosa

Description

@penalosa

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions