Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7b7c30
commit e90999f
Showing
6 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/nextjs/test/integration/pages/api/excludedEndpoints/excludedWithRegExp.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// This file will test the `excludeServerRoutes` option when a route is provided as a RegExp. | ||
const handler = async (): Promise<void> => { | ||
throw new Error('API Error'); | ||
}; | ||
|
||
export default handler; |
6 changes: 6 additions & 0 deletions
6
packages/nextjs/test/integration/pages/api/excludedEndpoints/excludedWithString.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// This file will test the `excludeServerRoutes` option when a route is provided as a string. | ||
const handler = async (): Promise<void> => { | ||
throw new Error('API Error'); | ||
}; | ||
|
||
export default handler; |
67 changes: 67 additions & 0 deletions
67
packages/nextjs/test/integration/test/server/excludedApiEndpoints.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const assert = require('assert'); | ||
|
||
const { sleep } = require('../utils/common'); | ||
const { getAsync, interceptEventRequest, interceptTracingRequest } = require('../utils/server'); | ||
|
||
module.exports = async ({ url: urlBase, argv }) => { | ||
const regExpUrl = `${urlBase}/api/excludedEndpoints/excludedWithRegExp`; | ||
const stringUrl = `${urlBase}/api/excludedEndpoints/excludedWithString`; | ||
|
||
const capturedRegExpErrorRequest = interceptEventRequest( | ||
{ | ||
exception: { | ||
values: [ | ||
{ | ||
type: 'Error', | ||
value: 'API Error', | ||
}, | ||
], | ||
}, | ||
tags: { | ||
runtime: 'node', | ||
}, | ||
request: { | ||
url: regExpUrl, | ||
method: 'GET', | ||
}, | ||
transaction: 'GET /api/excludedEndpoints/excludedWithRegExp', | ||
}, | ||
argv, | ||
'excluded API endpoint via RegExp', | ||
); | ||
|
||
const capturedStringErrorRequest = interceptEventRequest( | ||
{ | ||
exception: { | ||
values: [ | ||
{ | ||
type: 'Error', | ||
value: 'API Error', | ||
}, | ||
], | ||
}, | ||
tags: { | ||
runtime: 'node', | ||
}, | ||
request: { | ||
url: regExpUrl, | ||
method: 'GET', | ||
}, | ||
transaction: 'GET /api/excludedEndpoints/excludedWithString', | ||
}, | ||
argv, | ||
'excluded API endpoint via String', | ||
); | ||
|
||
await Promise.all([getAsync(regExpUrl), getAsync(stringUrl)]); | ||
await sleep(250); | ||
|
||
assert.ok( | ||
!capturedRegExpErrorRequest.isDone(), | ||
'Did intercept error request even though route should be excluded (RegExp)', | ||
); | ||
assert.ok( | ||
!capturedStringErrorRequest.isDone(), | ||
'Did intercept error request even though route should be excluded (String)', | ||
); | ||
}; |