Files
Real-US-Address-Generator-API/test/index.spec.js
严浩 c1f1f5d248 Initial commit (by create-cloudflare CLI)
Details:
  C3 = create-cloudflare@2.50.3
  project name = real-us-address-generator-api
  package manager = pnpm@10.13.1
  wrangler = wrangler@4.24.0
  git = 2.39.5 (Apple Git-154)
2025-07-15 23:09:32 +08:00

21 lines
902 B
JavaScript

import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
import { describe, it, expect } from 'vitest';
import worker from '../src';
describe('Hello World worker', () => {
it('responds with Hello World! (unit style)', async () => {
const request = new Request('http://example.com');
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
});
it('responds with Hello World! (integration style)', async () => {
const response = await SELF.fetch('http://example.com');
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
});
});