Skip to content

Commit 0b0142f

Browse files
committed
fix unit tests
1 parent 356461f commit 0b0142f

File tree

3 files changed

+35
-50
lines changed

3 files changed

+35
-50
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { isStaticAssetRequest } from '../../src/integrations/http/incoming-requests';
3+
4+
describe('httpIntegration', () => {
5+
describe('isStaticAssetRequest', () => {
6+
it.each([
7+
['/favicon.ico', true],
8+
['/apple-touch-icon.png', true],
9+
['/static/style.css', true],
10+
['/assets/app.js', true],
11+
['/fonts/font.woff2', true],
12+
['/images/logo.svg', true],
13+
['/img/photo.jpeg', true],
14+
['/img/photo.jpg', true],
15+
['/img/photo.jpg?v=123', true],
16+
['/img/photo.webp', true],
17+
['/font/font.ttf', true],
18+
['/robots.txt', true],
19+
['/sitemap.xml', true],
20+
['/manifest.json', true],
21+
['/browserconfig.xml', true],
22+
// non-static routes
23+
['/api/users', false],
24+
['/some-json.json', false],
25+
['/some-xml.xml', false],
26+
['/some-txt.txt', false],
27+
['/users', false],
28+
['/graphql', false],
29+
['/', false],
30+
])('returns %s -> %s', (urlPath, expected) => {
31+
expect(isStaticAssetRequest(urlPath)).toBe(expected);
32+
});
33+
});
34+
});

packages/node/src/integrations/http.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,3 @@ function getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrume
275275
return instrumentationConfig;
276276
}
277277

278-
/**
279-
* Check if a request is for a common static asset that should be ignored by default.
280-
*
281-
* Only exported for tests.
282-
*/
283-
export function isStaticAssetRequest(urlPath: string): boolean {
284-
const path = stripUrlQueryAndFragment(urlPath);
285-
// Common static file extensions
286-
if (path.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
287-
return true;
288-
}
289-
290-
// Common metadata files
291-
if (path.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
292-
return true;
293-
}
294-
295-
return false;
296-
}
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest';
2-
import { _shouldInstrumentSpans, isStaticAssetRequest } from '../../src/integrations/http';
2+
import { _shouldInstrumentSpans } from '../../src/integrations/http';
33
import { conditionalTest } from '../helpers/conditional';
44

55
describe('httpIntegration', () => {
@@ -27,34 +27,4 @@ describe('httpIntegration', () => {
2727
expect(actual).toBe(true);
2828
});
2929
});
30-
31-
describe('isStaticAssetRequest', () => {
32-
it.each([
33-
['/favicon.ico', true],
34-
['/apple-touch-icon.png', true],
35-
['/static/style.css', true],
36-
['/assets/app.js', true],
37-
['/fonts/font.woff2', true],
38-
['/images/logo.svg', true],
39-
['/img/photo.jpeg', true],
40-
['/img/photo.jpg', true],
41-
['/img/photo.jpg?v=123', true],
42-
['/img/photo.webp', true],
43-
['/font/font.ttf', true],
44-
['/robots.txt', true],
45-
['/sitemap.xml', true],
46-
['/manifest.json', true],
47-
['/browserconfig.xml', true],
48-
// non-static routes
49-
['/api/users', false],
50-
['/some-json.json', false],
51-
['/some-xml.xml', false],
52-
['/some-txt.txt', false],
53-
['/users', false],
54-
['/graphql', false],
55-
['/', false],
56-
])('returns %s -> %s', (urlPath, expected) => {
57-
expect(isStaticAssetRequest(urlPath)).toBe(expected);
58-
});
59-
});
6030
});

0 commit comments

Comments
 (0)