Initial commit (by create-cloudflare CLI)

Details:
  C3 = create-cloudflare@2.37.3
  project name = cf-basic-auth
  package manager = npm@10.9.2
  wrangler = wrangler@3.105.1
  git = 2.43.5
This commit is contained in:
2025-01-27 08:48:49 +00:00
commit 4d3614dc34
9 changed files with 2747 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
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!"`);
});
});