Unable to find Durable Objects (Typescript+Vitest+Miniflare)

Hi all. I have a Workers project using Typescript, Vitest, and Wrangler 2. The project worked fine right out of the box, and when I added the following to my vitest.config.ts:

export default defineConfig({
  test: {
    environment: "miniflare",
    environmentOptions: {
      modules: true,
      scriptPath: "./dist/index.js",
      durableObjects: {
        USER: "User",
      },
      bindings: { USER: "User" },
    },
  },
});

It complained that my Durable Objects couldn’t be found. Here’s my package.json:

"scripts": {
    "start": "wrangler dev",
    "deploy": "wrangler publish",
    "test": "npm run build && vitest",
    "build": "esbuild --bundle --sourcemap --outdir=dist ./src/index.js"
  },
  "main": "./dist/index.js",
  "type": "module"
}
"devDependencies": {
    "@cloudflare/workers-types": "^4.20230511.0",
    "esbuild": "^0.17.19",
    "miniflare": "^3.0.1",
    "typescript": "^5.0.4",
    "vitest": "^0.31.1",
    "vitest-environment-miniflare": "^2.14.0",
    "wrangler": "^2.20.0"
}

Does anyone know how to resolve this issue?

1 Like

@Jesse.S I’m facing the same issue now. Did you eve find a workaround for this?