Skip to content

Commit

Permalink
fix: remove invalid ctx import from hello-world experimental templa…
Browse files Browse the repository at this point in the history
…tes (#6839)

* fix: remove invalid `ctx` import from hello-world experimental templates

* fixup! fix: remove invalid `ctx` import from hello-world experimental templates

* fixup! fix: remove invalid `ctx` import from hello-world experimental templates
  • Loading branch information
petebacondarwin authored Oct 2, 2024
1 parent 3fa846e commit b0d514e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-bears-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

fix: remove invalid `ctx` import from hello-world experimental templates
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { env, ctx, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
import { describe, it, expect } from 'vitest';
import worker from '../src';

Expand All @@ -16,7 +16,7 @@ describe('Hello World user worker', () => {

it('responds with "Hello, World!" (integration style)', async () => {
const request = new Request('http://example.com/message');
const response = await SELF.fetch(request, env, ctx);
const response = await SELF.fetch(request);
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
});
});
Expand All @@ -34,7 +34,7 @@ describe('Hello World user worker', () => {

it('responds with a random UUID (integration style)', async () => {
const request = new Request('http://example.com/random');
const response = await SELF.fetch(request, env, ctx);
const response = await SELF.fetch(request);
expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { env, ctx, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
import { describe, it, expect } from 'vitest';
import worker from '../src';

describe('Hello World user worker', () => {
describe('request for /message', () => {
it('/ responds with "Hello, World!" (unit style)', async () => {
const request = new Request('http://example.com/message');
const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/message');
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
Expand All @@ -16,14 +16,14 @@ describe('Hello World user worker', () => {

it('responds with "Hello, World!" (integration style)', async () => {
const request = new Request('http://example.com/message');
const response = await SELF.fetch(request, env, ctx);
const response = await SELF.fetch(request);
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
});
});

describe('request for /random', () => {
it('/ responds with a random UUID (unit style)', async () => {
const request = new Request('http://example.com/random');
const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/random');
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
Expand All @@ -34,7 +34,7 @@ describe('Hello World user worker', () => {

it('responds with a random UUID (integration style)', async () => {
const request = new Request('http://example.com/random');
const response = await SELF.fetch(request, env, ctx);
const response = await SELF.fetch(request);
expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
});
});
Expand Down

0 comments on commit b0d514e

Please sign in to comment.