Skip to content

Commit

Permalink
Merge branch 'netlify:main' into refactor/replace-got/edge-functions.…
Browse files Browse the repository at this point in the history
…test.ts
  • Loading branch information
hereje authored Dec 13, 2023
2 parents 2b368bc + e3f654e commit ccef1ae
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions tests/integration/commands/dev/scheduled-functions.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import { describe, expect, test } from 'vitest'

import { FixtureTestContext, setupFixtureTests } from '../../utils/fixture.js'
import got from '../../utils/got.js'
import fetch from 'node-fetch'
import { pause } from '../../utils/pause.js'

describe('scheduled functions', () => {
setupFixtureTests('dev-server-with-functions', { devServer: true }, () => {
test<FixtureTestContext>('should emulate next_run for scheduled functions', async ({ devServer }) => {
const response = await got(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc`, {
throwHttpErrors: false,
retry: { limit: 0 },
})
const response = await fetch(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc`, {})

expect(response.statusCode).toBe(200)
expect(response.status).toBe(200)
})
})

setupFixtureTests('dev-server-with-functions', { devServer: true }, () => {
test<FixtureTestContext>('should detect file changes to scheduled function', async ({ devServer, fixture }) => {
const { body } = await got(`http://localhost:${devServer.port}/.netlify/functions/ping`, {
throwHttpErrors: false,
retry: { limit: 0 },
})
const body = await fetch(`http://localhost:${devServer.port}/.netlify/functions/ping`, {}).then((res) =>
res.text(),
)

expect(body).toBe('ping')

Expand All @@ -43,10 +39,9 @@ describe('scheduled functions', () => {
const DETECT_FILE_CHANGE_DELAY = 500
await pause(DETECT_FILE_CHANGE_DELAY)

const { body: warning } = await got(`http://localhost:${devServer.port}/.netlify/functions/ping`, {
throwHttpErrors: false,
retry: { limit: 0 },
})
const warning = await fetch(`http://localhost:${devServer.port}/.netlify/functions/ping`, {}).then((res) =>
res.text(),
)

expect(warning).toContain('Your function returned `body`')
})
Expand Down

0 comments on commit ccef1ae

Please sign in to comment.