|
1 | | -import type { Envelope, SerializedStreamedSpan, SerializedStreamedSpanContainer } from '@sentry/core'; |
2 | | -import { expect, it } from 'vitest'; |
3 | | -import { createRunner } from '../../runner'; |
| 1 | +import { afterAll, expect, test } from 'vitest'; |
| 2 | +import { cleanupChildProcesses, createRunner } from '../../../node-integration-tests/utils/runner'; |
4 | 3 |
|
5 | | -function getSpans(envelope: Envelope): SerializedStreamedSpan[] { |
6 | | - return (envelope[1][0][1] as SerializedStreamedSpanContainer).items; |
7 | | -} |
| 4 | +afterAll(() => { |
| 5 | + cleanupChildProcesses(); |
| 6 | +}); |
8 | 7 |
|
9 | 8 | // The runner always requests `http://localhost:<port>`, so only the `true` case is reachable here. |
10 | 9 | // The `false` case is covered by the unit tests for `isLocalhostRequest`. |
11 | | -it('sets sentry.is_localhost on every streamed span', async ({ signal }) => { |
12 | | - const runner = createRunner(__dirname) |
13 | | - .expect(envelope => { |
14 | | - const spans = getSpans(envelope); |
15 | | - |
16 | | - expect(spans.some(span => span.is_segment)).toBe(true); |
17 | | - expect(spans.some(span => span.name === 'child-span')).toBe(true); |
| 10 | +test('sets sentry.is_localhost on every streamed span', async () => { |
| 11 | + const runner = createRunner(__dirname, 'index.ts') |
| 12 | + .withMockSentryServer() |
| 13 | + .unordered() |
| 14 | + .expect({ |
| 15 | + span: container => { |
| 16 | + expect(container.items.some(span => span.is_segment)).toBe(true); |
| 17 | + expect(container.items.some(span => span.name === 'child-span')).toBe(true); |
18 | 18 |
|
19 | | - for (const span of spans) { |
20 | | - expect(span.attributes['sentry.is_localhost']).toEqual({ value: true, type: 'boolean' }); |
21 | | - } |
| 19 | + for (const span of container.items) { |
| 20 | + expect(span.attributes['sentry.is_localhost']).toEqual({ value: true, type: 'boolean' }); |
| 21 | + } |
| 22 | + }, |
22 | 23 | }) |
23 | | - .start(signal); |
| 24 | + .start(); |
24 | 25 |
|
25 | 26 | await runner.makeRequest('get', '/'); |
26 | 27 | await runner.completed(); |
|
0 commit comments