---
title: Test Durable Object eviction with new cloudflare:test helpers
description: evictDurableObject and evictAllDurableObjects let you test how Durable Objects behave across evictions in your Vitest tests.
image: https://edgetunnel-b2h.pages.dev/changelog-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://edgetunnel-b2h.pages.dev/changelog/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Changelog

New updates and improvements at Cloudflare.

[ Subscribe to RSS ](https://edgetunnel-b2h.pages.dev/changelog/rss/index.xml) [ View RSS feeds ](https://edgetunnel-b2h.pages.dev/fundamentals/new-features/available-rss-feeds/) 

![hero image](https://edgetunnel-b2h.pages.dev/_astro/hero.CVYJHPAd_26AMqX.svg) 

[ ← Back to all posts ](https://edgetunnel-b2h.pages.dev/changelog/) 

## Test Durable Object eviction with new cloudflare:test helpers

Jun 25, 2026 

[ Durable Objects ](https://edgetunnel-b2h.pages.dev/durable-objects/)[ Workers ](https://edgetunnel-b2h.pages.dev/workers/) 

The `@cloudflare/vitest-pool-workers` package now includes `evictDurableObject` and `evictAllDurableObjects` test helpers, exported from `cloudflare:test`.

These helpers let you test how a Durable Object behaves across evictions, simulating the production lifecycle where an idle Durable Object can be evicted from memory.

For more context, refer to [Lifecycle of a Durable Object](https://edgetunnel-b2h.pages.dev/durable-objects/concepts/durable-object-lifecycle/).

**TypeScript**

```ts
import { evictDurableObject, evictAllDurableObjects } from "cloudflare:test";
import { env } from "cloudflare:workers";


const id = env.COUNTER.idFromName("my-counter");
const stub = env.COUNTER.get(id);


// Evict the Durable Object instance pointed to by a specific stub
await evictDurableObject(stub);


// Close WebSockets instead of hibernating them
await evictDurableObject(stub, { webSockets: "close" });


// Evict all currently-running Durable Objects in evictable namespaces
await evictAllDurableObjects();
```

These helpers are available in `@cloudflare/vitest-pool-workers@0.16.20` and later.

Learn more in the [Test APIs reference](https://edgetunnel-b2h.pages.dev/workers/testing/vitest-integration/test-apis/#durable-objects) and the [Testing Durable Objects guide](https://edgetunnel-b2h.pages.dev/durable-objects/examples/testing-with-durable-objects/#testing-eviction).

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://edgetunnel-b2h.pages.dev/changelog/post/2026-06-25-durable-object-eviction-test-helpers/#page","headline":"Test Durable Object eviction with new cloudflare:test helpers · Changelog","description":"evictDurableObject and evictAllDurableObjects let you test how Durable Objects behave across evictions in your Vitest tests.","url":"https://edgetunnel-b2h.pages.dev/changelog/post/2026-06-25-durable-object-eviction-test-helpers/","inLanguage":"en","image":"https://edgetunnel-b2h.pages.dev/changelog-preview.png","dateModified":"2026-06-25","datePublished":"2026-06-25","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://edgetunnel-b2h.pages.dev/#website","name":"Cloudflare Docs","url":"https://edgetunnel-b2h.pages.dev/"}}
```
