-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
excludedApiEndpoints.js
67 lines (61 loc) · 1.63 KB
/
excludedApiEndpoints.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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)',
);
};