Skip to content

Commit

Permalink
Bump versions to 2.11.0, update CHANGELOG.md and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbbot committed Oct 27, 2022
1 parent 1a21f6b commit 07f3122
Show file tree
Hide file tree
Showing 29 changed files with 449 additions and 382 deletions.
27 changes: 27 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# 🚧 Changelog

## 2.11.0

### Features

- Add support for dead-letter queues. Thanks
[@jbw1991](https://github.com/jbw1991) for
[the PR](https://github.com/cloudflare/miniflare/pull/411).
- Add `getMiniflareDurableObjectIds()` global function to Miniflare's
Jest/Vitest environments for listing active Durable Objects. Calling
`getMiniflareDurableObjectIds("TEST_OBJECT")` will return a `Promise` that
resolves to an array of active `DurableObjectId`s for the `TEST_OBJECT`
namespace. Closes
[issue #384](https://github.com/cloudflare/miniflare/issues/384), thanks
[@DaniFoldi](https://github.com/DaniFoldi) for
[the PR](https://github.com/cloudflare/miniflare/pull/413).

### Fixes

- Strip quotes from R2 `onlyIf` header values. Closes
[issue #402](https://github.com/cloudflare/miniflare/issues/402), thanks
[@vincentbernat](https://github.com/vincentbernat) and
[@CraigglesO](https://github.com/CraigglesO) for
[the PR](https://github.com/cloudflare/miniflare/pull/403).
- Disable `r2Persist` option in Miniflare's Jest/Vitest environments. Thanks
[@hanford](https://github.com/hanford) for
[the PR](https://github.com/cloudflare/miniflare/pull/414).

## 2.10.0

### Features
Expand Down
18 changes: 18 additions & 0 deletions docs/src/content/testing/jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,24 @@ test("flushes alarms", async () => {
});
```
To list all active Durable Objects in a namespace, use the
`getMiniflareDurableObjectIds()` global function:
```js
test("gets objects", async () => {
// Get Durable Object stub
const env = getMiniflareBindings();
const id = env.TEST_OBJECT.newUniqueId();
const stub = env.TEST_OBJECT.get(id);
await stub.fetch("http://localhost/");

// Get all active TEST_OBJECT Durable Object IDs
const ids = await getMiniflareDurableObjectIds("TEST_OBJECT");
expect(ids).toHaveLength(1);
expect(ids[0].toString()).toBe(id.toString());
});
```
### Constructing Durable Objects Directly
Alternatively, you can construct instances of your Durable Object using
Expand Down
30 changes: 26 additions & 4 deletions docs/src/content/testing/vitest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ order: 1

# ⚡️ Vitest Environment

Miniflare includes a custom [Vitest](https://vitest.dev/) environment that allows you to run your unit
tests within the Miniflare sandbox. Note that Vitest 0.23.0 is required.
Miniflare includes a custom [Vitest](https://vitest.dev/) environment that
allows you to run your unit tests within the Miniflare sandbox. Note that Vitest
0.23.0 is required.

## Setup

Expand All @@ -21,8 +22,8 @@ In the following examples, we'll assume your `package.json` contains
[⚡️ Developing with esbuild](/developing/esbuild) for an example.

To enable the Miniflare environment, set the
[`environment` option](https://vitest.dev/config/#environment)
in your Vitest configuration:
[`environment` option](https://vitest.dev/config/#environment) in your Vitest
configuration:

```ts
---
Expand Down Expand Up @@ -294,6 +295,27 @@ test("flushes alarms", async () => {
});
```
To list all active Durable Objects in a namespace, use the
`getMiniflareDurableObjectIds()` global function:
```js
import { expect, test } from "vitest";
const describe = setupMiniflareIsolatedStorage();

test("gets objects", async () => {
// Get Durable Object stub
const env = getMiniflareBindings();
const id = env.TEST_OBJECT.newUniqueId();
const stub = env.TEST_OBJECT.get(id);
await stub.fetch("http://localhost/");

// Get all active TEST_OBJECT Durable Object IDs
const ids = await getMiniflareDurableObjectIds("TEST_OBJECT");
expect(ids).toHaveLength(1);
expect(ids[0].toString()).toBe(id.toString());
});
```
### Constructing Durable Objects Directly
Alternatively, you can construct instances of your Durable Object using
Expand Down
Loading

0 comments on commit 07f3122

Please sign in to comment.