Skip to content

Commit 931ae71

Browse files
committed
add integration tests
1 parent 807f342 commit 931ae71

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed

packages/nextjs/test/integration/next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const moduleExports = {
99
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
1010
// TODO (v8): This can come out in v8, because this option will get a default value
1111
hideSourceMaps: false,
12+
excludeServerRoutes: ['/api/excludedEndpoints/excludedWithString', /\/api\/excludedEndpoints\/excludedWithRegExp/],
1213
},
1314
};
1415
const SentryWebpackPluginOptions = {

packages/nextjs/test/integration/next10.config.template

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const moduleExports = {
1010
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
1111
// TODO (v8): This can come out in v8, because this option will get a default value
1212
hideSourceMaps: false,
13+
excludeServerRoutes: [
14+
'/api/excludedEndpoints/excludedWithString',
15+
/\/api\/excludedEndpoints\/excludedWithRegExp/,
16+
],
1317
},
1418
};
1519

packages/nextjs/test/integration/next11.config.template

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const moduleExports = {
1111
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
1212
// TODO (v8): This can come out in v8, because this option will get a default value
1313
hideSourceMaps: false,
14+
excludeServerRoutes: [
15+
'/api/excludedEndpoints/excludedWithString',
16+
/\/api\/excludedEndpoints\/excludedWithRegExp/,
17+
],
1418
},
1519
};
1620

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This file will test the `excludeServerRoutes` option when a route is provided as a RegExp.
2+
const handler = async (): Promise<void> => {
3+
throw new Error('API Error');
4+
};
5+
6+
export default handler;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This file will test the `excludeServerRoutes` option when a route is provided as a string.
2+
const handler = async (): Promise<void> => {
3+
throw new Error('API Error');
4+
};
5+
6+
export default handler;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const assert = require('assert');
2+
3+
const { sleep } = require('../utils/common');
4+
const { getAsync, interceptEventRequest, interceptTracingRequest } = require('../utils/server');
5+
6+
module.exports = async ({ url: urlBase, argv }) => {
7+
const regExpUrl = `${urlBase}/api/excludedEndpoints/excludedWithRegExp`;
8+
const stringUrl = `${urlBase}/api/excludedEndpoints/excludedWithString`;
9+
10+
const capturedRegExpErrorRequest = interceptEventRequest(
11+
{
12+
exception: {
13+
values: [
14+
{
15+
type: 'Error',
16+
value: 'API Error',
17+
},
18+
],
19+
},
20+
tags: {
21+
runtime: 'node',
22+
},
23+
request: {
24+
url: regExpUrl,
25+
method: 'GET',
26+
},
27+
transaction: 'GET /api/excludedEndpoints/excludedWithRegExp',
28+
},
29+
argv,
30+
'excluded API endpoint via RegExp',
31+
);
32+
33+
const capturedStringErrorRequest = interceptEventRequest(
34+
{
35+
exception: {
36+
values: [
37+
{
38+
type: 'Error',
39+
value: 'API Error',
40+
},
41+
],
42+
},
43+
tags: {
44+
runtime: 'node',
45+
},
46+
request: {
47+
url: regExpUrl,
48+
method: 'GET',
49+
},
50+
transaction: 'GET /api/excludedEndpoints/excludedWithString',
51+
},
52+
argv,
53+
'excluded API endpoint via String',
54+
);
55+
56+
await Promise.all([getAsync(regExpUrl), getAsync(stringUrl)]);
57+
await sleep(250);
58+
59+
assert.ok(
60+
!capturedRegExpErrorRequest.isDone(),
61+
'Did intercept error request even though route should be excluded (RegExp)',
62+
);
63+
assert.ok(
64+
!capturedStringErrorRequest.isDone(),
65+
'Did intercept error request even though route should be excluded (String)',
66+
);
67+
};

0 commit comments

Comments
 (0)