I just released `@lumenize/testing` which builds on `cloudflare:test` vitest integration. See: https

I just released
@lumenize/testing
which builds on
cloudflare:test
vitest integration. See: https://lumenize.com/docs/testing/usage#basic-usage. Example:
it('shows basic 5-step test', async () => {
  // 1. Create RPC testing client and Browser instance
  await using client = createTestingClient<MyDOType>('MY_DO', '5-step');
  const browser = new Browser();

  // 2. Pre-populate storage via RPC to call asycn KV API
  await client.ctx.storage.put('count', 10);

  // 3. Make a fetch and RPC call to increment
  const resp = await browser.fetch('https://test.com/my-do/5-step/increment');
  const rpcResult = await client.increment();

  // 4. Confirm that results are as expected
  expect(await resp.text()).toBe('11');
  expect(rpcResult).toBe(12);  // Notice this is a number not a string

  // 5. Verify that storage is correct via RPC
  expect(await client.ctx.storage.kv.get('count')).toBe(12);
});

Let me know what you think or if you have any questions.
📘 Doc-testing – Why do these examples look like tests?
Was this page helpful?