I'm getting this error with the
I'm getting this error with the cloudflare blank starter repo when I change the index.ts to use workflows (the test passed before0
[vpw:inf] Starting isolated runtimes for vitest.config.mts...
Worker "workflows:telegram-mod-wf"'s binding "USER_WORKFLOW" refers to service "core:user:vitest-pool-workers-runner-" with a named entrypoint "MessageHandler", but "core:user:vitest-pool-workers-runner-" has no such named entrypoint.
WARN - IDE integration: Got finished tests before collecting them
WARN - IDE integration: Cannot finish not started testing
[vpw:inf] Starting isolated runtimes for vitest.config.mts...
Worker "workflows:telegram-mod-wf"'s binding "USER_WORKFLOW" refers to service "core:user:vitest-pool-workers-runner-" with a named entrypoint "MessageHandler", but "core:user:vitest-pool-workers-runner-" has no such named entrypoint.
WARN - IDE integration: Got finished tests before collecting them
WARN - IDE integration: Cannot finish not started testing
1 Reply
my (vi)test file (it's almost the same as the default)
my index file
gotcha thx
ah perfect thank you for this!
// test/index.spec.ts
import {
createExecutionContext,
env,
SELF,
waitOnExecutionContext,
} from "cloudflare:test";
import { describe, expect, it } from "vitest";
import worker from "../src/index";
const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;
describe("Hello World worker", () => {
it("responds with Hello World! (unit style)", async () => {
const request = new IncomingRequest("http://example.com");
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env as any, ctx);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});
it("responds with Hello World! (integration style)", async () => {
const response = await SELF.fetch("https://example.com");
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});
});
// test/index.spec.ts
import {
createExecutionContext,
env,
SELF,
waitOnExecutionContext,
} from "cloudflare:test";
import { describe, expect, it } from "vitest";
import worker from "../src/index";
const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;
describe("Hello World worker", () => {
it("responds with Hello World! (unit style)", async () => {
const request = new IncomingRequest("http://example.com");
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env as any, ctx);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});
it("responds with Hello World! (integration style)", async () => {
const response = await SELF.fetch("https://example.com");
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});
});
export class MessageHandler extends WorkflowEntrypoint<Env, Queue> {
public async run(event: WorkflowEvent<Queue>, step: WorkflowStep) {
// ...
}
}
export default {
async fetch(request, env, _ctx): Promise<Response> {
if (request.method === "GET") {
return new Response("Not found", { status: 404 });
}
}
}
export class MessageHandler extends WorkflowEntrypoint<Env, Queue> {
public async run(event: WorkflowEvent<Queue>, step: WorkflowStep) {
// ...
}
}
export default {
async fetch(request, env, _ctx): Promise<Response> {
if (request.method === "GET") {
return new Response("Not found", { status: 404 });
}
}
}