I am trying to directly access a durable

I am trying to directly access a durable object in my tests to run the alarm, but I am unsure how to correctly add the binding to my test env without getting type errors
1 Reply
King Kazu
King KazuOP4mo ago
Here is my .env.d.ts
import { RateLimiter } from '../src';

declare module 'cloudflare:test' {
interface ProvidedEnv {
RateLimitDo: RateLimiter;
}
}
import { RateLimiter } from '../src';

declare module 'cloudflare:test' {
interface ProvidedEnv {
RateLimitDo: RateLimiter;
}
}
vitest.config.js
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';

export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
singleWorker: true,
wrangler: { configPath: './wrangler.toml' },
},
},
},
});
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';

export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
singleWorker: true,
wrangler: { configPath: './wrangler.toml' },
},
},
},
});
but when I try to run
const id = env.RateLimitDo.newUniqueId();
const id = env.RateLimitDo.newUniqueId();
, I get the type error Property 'newUniqueId' does not exist on type 'RateLimiter'
Want results from more Discord servers?
Add your server