|
1 |
| -import { describe, expect, test } from 'vitest'; |
2 |
| -import { createRunner } from '../../../../utils/runner'; |
| 1 | +import { describe, expect } from 'vitest'; |
| 2 | +import { createEsmAndCjsTests } from '../../../../utils/runner'; |
3 | 3 | import { createTestServer } from '../../../../utils/server';
|
4 | 4 |
|
5 | 5 | describe('outgoing fetch', () => {
|
6 |
| - test('outgoing fetch requests create breadcrumbs', async () => { |
7 |
| - const [SERVER_URL, closeTestServer] = await createTestServer().start(); |
| 6 | + createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { |
| 7 | + test('outgoing fetch requests create breadcrumbs xxx', async () => { |
| 8 | + const [SERVER_URL, closeTestServer] = await createTestServer().start(); |
8 | 9 |
|
9 |
| - await createRunner(__dirname, 'scenario.ts') |
10 |
| - .withEnv({ SERVER_URL }) |
11 |
| - .ensureNoErrorOutput() |
12 |
| - .expect({ |
13 |
| - event: { |
14 |
| - breadcrumbs: [ |
15 |
| - { |
16 |
| - message: 'manual breadcrumb', |
17 |
| - timestamp: expect.any(Number), |
18 |
| - }, |
19 |
| - { |
20 |
| - category: 'http', |
21 |
| - data: { |
22 |
| - 'http.method': 'GET', |
23 |
| - url: `${SERVER_URL}/api/v0`, |
24 |
| - status_code: 404, |
25 |
| - ADDED_PATH: '/api/v0', |
| 10 | + await createRunner() |
| 11 | + .withEnv({ SERVER_URL }) |
| 12 | + .expect({ |
| 13 | + event: { |
| 14 | + breadcrumbs: [ |
| 15 | + { |
| 16 | + message: 'manual breadcrumb', |
| 17 | + timestamp: expect.any(Number), |
26 | 18 | },
|
27 |
| - timestamp: expect.any(Number), |
28 |
| - type: 'http', |
29 |
| - }, |
30 |
| - { |
31 |
| - category: 'http', |
32 |
| - data: { |
33 |
| - 'http.method': 'GET', |
34 |
| - url: `${SERVER_URL}/api/v1`, |
35 |
| - status_code: 404, |
36 |
| - ADDED_PATH: '/api/v1', |
| 19 | + { |
| 20 | + category: 'http', |
| 21 | + data: { |
| 22 | + 'http.method': 'GET', |
| 23 | + url: `${SERVER_URL}/api/v0`, |
| 24 | + status_code: 404, |
| 25 | + ADDED_PATH: '/api/v0', |
| 26 | + }, |
| 27 | + timestamp: expect.any(Number), |
| 28 | + type: 'http', |
37 | 29 | },
|
38 |
| - timestamp: expect.any(Number), |
39 |
| - type: 'http', |
40 |
| - }, |
41 |
| - { |
42 |
| - category: 'http', |
43 |
| - data: { |
44 |
| - 'http.method': 'GET', |
45 |
| - url: `${SERVER_URL}/api/v2`, |
46 |
| - status_code: 404, |
47 |
| - ADDED_PATH: '/api/v2', |
| 30 | + { |
| 31 | + category: 'http', |
| 32 | + data: { |
| 33 | + 'http.method': 'GET', |
| 34 | + url: `${SERVER_URL}/api/v1`, |
| 35 | + status_code: 404, |
| 36 | + ADDED_PATH: '/api/v1', |
| 37 | + }, |
| 38 | + timestamp: expect.any(Number), |
| 39 | + type: 'http', |
48 | 40 | },
|
49 |
| - timestamp: expect.any(Number), |
50 |
| - type: 'http', |
51 |
| - }, |
52 |
| - { |
53 |
| - category: 'http', |
54 |
| - data: { |
55 |
| - 'http.method': 'GET', |
56 |
| - url: `${SERVER_URL}/api/v3`, |
57 |
| - status_code: 404, |
58 |
| - ADDED_PATH: '/api/v3', |
| 41 | + { |
| 42 | + category: 'http', |
| 43 | + data: { |
| 44 | + 'http.method': 'GET', |
| 45 | + url: `${SERVER_URL}/api/v2`, |
| 46 | + status_code: 404, |
| 47 | + ADDED_PATH: '/api/v2', |
| 48 | + }, |
| 49 | + timestamp: expect.any(Number), |
| 50 | + type: 'http', |
59 | 51 | },
|
60 |
| - timestamp: expect.any(Number), |
61 |
| - type: 'http', |
62 |
| - }, |
63 |
| - ], |
64 |
| - exception: { |
65 |
| - values: [ |
66 | 52 | {
|
67 |
| - type: 'Error', |
68 |
| - value: 'foo', |
| 53 | + category: 'http', |
| 54 | + data: { |
| 55 | + 'http.method': 'GET', |
| 56 | + url: `${SERVER_URL}/api/v3`, |
| 57 | + status_code: 404, |
| 58 | + ADDED_PATH: '/api/v3', |
| 59 | + }, |
| 60 | + timestamp: expect.any(Number), |
| 61 | + type: 'http', |
69 | 62 | },
|
70 | 63 | ],
|
| 64 | + exception: { |
| 65 | + values: [ |
| 66 | + { |
| 67 | + type: 'Error', |
| 68 | + value: 'foo', |
| 69 | + }, |
| 70 | + ], |
| 71 | + }, |
71 | 72 | },
|
72 |
| - }, |
73 |
| - }) |
74 |
| - .start() |
75 |
| - .completed(); |
76 |
| - closeTestServer(); |
| 73 | + }) |
| 74 | + .start() |
| 75 | + .completed(); |
| 76 | + |
| 77 | + closeTestServer(); |
| 78 | + }); |
77 | 79 | });
|
78 | 80 | });
|
0 commit comments