-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathserver.test.ts
37 lines (28 loc) · 1.11 KB
/
server.test.ts
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
import { getTraceMetaTags } from '@sentry/core';
import { type Mock, afterEach, describe, expect, it, vi } from 'vitest';
import { addSentryTracingMetaTags } from '../../../src/runtime/utils';
vi.mock('@sentry/core', () => ({
getTraceMetaTags: vi.fn(),
}));
describe('addSentryTracingMetaTags', () => {
afterEach(() => {
vi.resetAllMocks();
});
it('should add meta tags to the head array', () => {
const mockMetaTags = [
'<meta name="sentry-trace" content="12345678901234567890123456789012-1234567890123456-1"/>',
'<meta name="baggage" content="sentry-environment=production"/>',
].join('\n');
// return value is mocked here as return values of `getTraceMetaTags` are tested separately (in @sentry/core)
(getTraceMetaTags as Mock).mockReturnValue(mockMetaTags);
const head: string[] = [];
addSentryTracingMetaTags(head);
expect(head).toContain(mockMetaTags);
});
it('should handle empty meta tags', () => {
(getTraceMetaTags as Mock).mockReturnValue('');
const head: string[] = [];
addSentryTracingMetaTags(head);
expect(head).toHaveLength(0);
});
});