Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Oct 31, 2023
1 parent f0ea58b commit 3a24dfa
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
publish = "public"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
origin
38 changes: 22 additions & 16 deletions tests/integration/commands/dev/edge-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const setup = async ({ fixture }) => {
}

describe.skipIf(isWindows)('edge functions', () => {
setupFixtureTests('dev-server-with-edge-functions', { devServer: true, mockApi: { routes }, setup }, () => {
setupFixtureTests('dev-server-with-edge-functions', { devServer: true, mockApi: { routes } }, () => {
test<FixtureTestContext>('should run edge functions in correct order', async ({ devServer }) => {
const response = await got(`http://localhost:${devServer.port}/ordertest`, {
throwHttpErrors: false,
Expand Down Expand Up @@ -120,21 +120,6 @@ describe.skipIf(isWindows)('edge functions', () => {

expect(res2.body).toContain('<p>An unhandled error in the function code triggered the following message:</p>')
})

test<FixtureTestContext>('should run an edge function that uses the Blobs npm module', async ({ devServer }) => {
const res = await got(`http://localhost:${devServer.port}/blobs`, {
method: 'GET',
throwHttpErrors: false,
retry: { limit: 0 },
})

expect(res.statusCode).toBe(200)
expect(JSON.parse(res.body)).toEqual({
data: 'hello world',
fresh: false,
metadata: { name: 'Netlify', features: { blobs: true, functions: true } },
})
})
})

setupFixtureTests('dev-server-with-edge-functions', { devServer: true, mockApi: { routes } }, () => {
Expand All @@ -155,4 +140,25 @@ describe.skipIf(isWindows)('edge functions', () => {
expect(devServer.output).not.toContain('Removed edge function')
})
})

setupFixtureTests(
'dev-server-with-edge-functions-and-npm-modules',
{ devServer: true, mockApi: { routes }, setup },
() => {
test<FixtureTestContext>('should run an edge function that uses the Blobs npm module', async ({ devServer }) => {
const res = await got(`http://localhost:${devServer.port}/blobs`, {
method: 'GET',
throwHttpErrors: false,
retry: { limit: 0 },
})

expect(res.statusCode).toBe(200)
expect(JSON.parse(res.body)).toEqual({
data: 'hello world',
fresh: false,
metadata: { name: 'Netlify', features: { blobs: true, functions: true } },
})
})
},
)
})

0 comments on commit 3a24dfa

Please sign in to comment.