Help setting up tests for Durable

Help setting up tests for Durable Objects. reference: https://github.com/withastro/astro/pull/8654
1 Reply
alex (he/him)
alex (he/him)OP14mo ago
@MrBBot thx for helping out!
# wrangler.toml
name = "test"

[[durable_objects.bindings]]
name = "DO"
class_name = "DurableObjectExample"
# wrangler.toml
name = "test"

[[durable_objects.bindings]]
name = "DO"
class_name = "DurableObjectExample"
// .ts
const DOBindings = { DO: { className: 'DurableObjectExample' } }

new Miniflare({
modules: true,
script: '',
cache: true,
cachePersist: true,
cacheWarnUsage: true,
durableObjects: DOBindings,
durableObjectsPersist: true,
});
// .ts
const DOBindings = { DO: { className: 'DurableObjectExample' } }

new Miniflare({
modules: true,
script: '',
cache: true,
cachePersist: true,
cacheWarnUsage: true,
durableObjects: DOBindings,
durableObjectsPersist: true,
});
If I understand it correctly, the Durable Object Class (e.g. DurableObjectExample), needs to be in the worker script. But given that is a automatic SSR bundle for Astro, I really don't know how to write/create a durable object in that case. I think the main usage would be to have access to durable objects which you deploy seperate to your CF Pages Astro site, but then how would that work for local dev or unit testing? Please ask, if anything unclear. ohh nvm.. maybe I did something wrong. My wrangler had a "placeholder" script_name included (https://developers.cloudflare.com/durable-objects/get-started/#5-configure-durable-object-bindings). Just removing the script_name it seems to work, now!
Want results from more Discord servers?
Add your server