Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Request_2 is not exported from cli.ts #3747

Closed
shaunco opened this issue Aug 13, 2023 · 1 comment
Closed

🐛 BUG: Request_2 is not exported from cli.ts #3747

shaunco opened this issue Aug 13, 2023 · 1 comment
Labels
bug Something that isn't working

Comments

@shaunco
Copy link

shaunco commented Aug 13, 2023

Which Cloudflare product(s) does this pertain to?

Wrangler core

What version(s) of the tool(s) are you using?

3.5.0

What version of Node are you using?

18.6.1

What operating system are you using?

Windows

Describe the Bug

When trying to make requests from a unit test, the old Request type no longer satisfies the RequestInfo_2 subtype of Request_2 and Request_2 is not exported. This means requests can only be made by a string URL which prevents tests using HTTP request types other than GET or setting custom headers in the request.

Example code that no longer works in TypeScript:

import { unstable_dev, UnstableDevWorker } from 'wrangler';

describe('worker', () => {
  let worker: UnstableDevWorker;

  beforeAll(async () => {
		worker = await unstable_dev('src/index.ts', {}, { disableExperimentalWarning: true });
	});

	afterAll(async () => {
		await worker.stop();
	});  

  it('Should return 200 response', async () => {
    const req = new Request('http://someurl.com/', { method: 'GET' });
    const res = await worker.fetch(req);
    expect(res.status).toBe(200)
  })
})

TypeScript gives an error of:

error TS2345: Argument of type 'Request<unknown, CfProperties<unknown>>' is not assignable to parameter of type 'RequestInfo_2 | undefined'.                              
      Type 'Request<unknown, CfProperties<unknown>>' is missing the following properties from type 'Request_2': cache, credentials, destination, mode, and 2 more

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@shaunco shaunco added the bug Something that isn't working label Aug 13, 2023
@shaunco shaunco closed this as completed Aug 25, 2023
@ianduvall
Copy link

This is still an issue in the latest version of wrangler (3.11.0). Can we reopen this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

2 participants