Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

POST requests to Netlify Functions weren't working with @netlify/dev and the Vite plugin. The functionality was fixed but test coverage was missing for non-GET HTTP methods.

Changes

Added test coverage for POST, PUT, DELETE, and PATCH requests across key packages:

@netlify/functions-dev (4 tests)

  • POST with JSON body
  • PUT with path parameters and body
  • DELETE with path parameters
  • PATCH with JSON body

@netlify/dev (3 integration tests)

  • POST to functions with JSON body
  • PUT with path parameters
  • DELETE with path parameters

@netlify/edge-functions-dev (4 tests, skipped)

  • Tests for POST, PUT, DELETE, PATCH
  • Skipped due to pre-existing Deno environment issues in test suite

@netlify/vite-plugin (3 tests)

  • POST to functions
  • PUT to functions
  • POST to edge functions

Example

test('Handles POST requests with body', async () => {
  const fixture = new Fixture().withFile(
    'netlify/functions/echo.mjs',
    `export default async (req) => {
      const body = await req.text()
      return new Response(JSON.stringify({
        method: req.method,
        body: body
      }), {
        headers: { 'Content-Type': 'application/json' }
      })
    }`,
  )
  
  const req = new Request('https://site.netlify/.netlify/functions/echo', {
    method: 'POST',
    body: JSON.stringify({ message: 'Hello' }),
    headers: { 'Content-Type': 'application/json' },
  })
  
  const match = await functions.match(req, destPath)
  const res = await match!.handle(req)
  expect(res?.status).toBe(200)
  expect(await res?.json()).toEqual({
    method: 'POST',
    body: JSON.stringify({ message: 'Hello' }),
  })
})
Original prompt

Issue Title: Add test coverage for non-GET requests to NFs and EFs
Issue Description: POST requests to NFs weren't working with @netlify/dev and the Vite plugin. We fixed it but didn't add test coverage.
Fixes https://linear.app/netlify/issue/FRB-1879/add-test-coverage-for-non-get-requests-to-nfs-and-efs

Comment by User db2967f5-c49c-428b-ae14-6c61855027c1:
netlify/primitives

Comment by User c8ba5c18-8b2b-41c2-8484-9ca4ad793475:
📋 I wasn't able to determine which GitHub repository to work in.

Please tell me which repository this work should be done in using the format owner/repository-name (e.g., github/copilot), then I'll automatically start working on it!

Comment by User :
This thread is for an agent session with githubcopilot.

Comment by User e186620e-0ca5-4c3e-8da4-8665bb797a9b:
Cloud Agent requires at least $2 remaining until your hard limit. Please increase your hard limit or enable usage-based pricing.

Try again or contact Cursor support at hi@cursor.com.

Request ID: serverGenReqId_39cb84b5-454f-4685-b4f8-3b01e7b39a1c

Comment by User :
This thread is for an agent session with cursor.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 5, 2025 16:31
Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
Co-authored-by: serhalp <1377702+serhalp@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test coverage for non-POST requests to NFs and EFs Add test coverage for non-GET HTTP methods in NFs and EFs Nov 5, 2025
Copilot AI requested a review from serhalp November 5, 2025 16:41
Copilot finished work on behalf of serhalp November 5, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants