|
1 |
| -import nock from 'nock'; |
2 |
| - |
3 |
| -import { TestEnv, runScenario } from '../../../utils'; |
4 |
| - |
5 |
| -// TODO: Convert this test to the new test runner |
6 |
| -// eslint-disable-next-line jest/no-disabled-tests |
7 |
| -test.skip('HttpIntegration should instrument correct requests when tracePropagationTargets option is provided', async () => { |
8 |
| - const match1 = nock('http://match-this-url.com') |
9 |
| - .get('/api/v0') |
10 |
| - .matchHeader('baggage', val => typeof val === 'string') |
11 |
| - .matchHeader('sentry-trace', val => typeof val === 'string') |
12 |
| - .reply(200); |
13 |
| - |
14 |
| - const match2 = nock('http://match-this-url.com') |
15 |
| - .get('/api/v1') |
16 |
| - .matchHeader('baggage', val => typeof val === 'string') |
17 |
| - .matchHeader('sentry-trace', val => typeof val === 'string') |
18 |
| - .reply(200); |
19 |
| - |
20 |
| - const match3 = nock('http://dont-match-this-url.com') |
21 |
| - .get('/api/v2') |
22 |
| - .matchHeader('baggage', val => val === undefined) |
23 |
| - .matchHeader('sentry-trace', val => val === undefined) |
24 |
| - .reply(200); |
25 |
| - |
26 |
| - const match4 = nock('http://dont-match-this-url.com') |
27 |
| - .get('/api/v3') |
28 |
| - .matchHeader('baggage', val => val === undefined) |
29 |
| - .matchHeader('sentry-trace', val => val === undefined) |
30 |
| - .reply(200); |
31 |
| - |
32 |
| - const env = await TestEnv.init(__dirname); |
33 |
| - await runScenario(env.url); |
34 |
| - |
35 |
| - env.server.close(); |
36 |
| - nock.cleanAll(); |
37 |
| - |
38 |
| - await new Promise(resolve => env.server.close(resolve)); |
39 |
| - |
40 |
| - expect(match1.isDone()).toBe(true); |
41 |
| - expect(match2.isDone()).toBe(true); |
42 |
| - expect(match3.isDone()).toBe(true); |
43 |
| - expect(match4.isDone()).toBe(true); |
| 1 | +import { createRunner } from '../../../utils/runner'; |
| 2 | +import { createTestServer } from '../../../utils/server'; |
| 3 | + |
| 4 | +test('HttpIntegration should instrument correct requests when tracePropagationTargets option is provided', done => { |
| 5 | + expect.assertions(9); |
| 6 | + |
| 7 | + createTestServer(done) |
| 8 | + .get('/api/v0', headers => { |
| 9 | + expect(typeof headers['baggage']).toBe('string'); |
| 10 | + expect(typeof headers['sentry-trace']).toBe('string'); |
| 11 | + }) |
| 12 | + .get('/api/v1', headers => { |
| 13 | + expect(typeof headers['baggage']).toBe('string'); |
| 14 | + expect(typeof headers['sentry-trace']).toBe('string'); |
| 15 | + }) |
| 16 | + .get('/api/v2', headers => { |
| 17 | + expect(headers['baggage']).toBeUndefined(); |
| 18 | + expect(headers['sentry-trace']).toBeUndefined(); |
| 19 | + }) |
| 20 | + .get('/api/v3', headers => { |
| 21 | + expect(headers['baggage']).toBeUndefined(); |
| 22 | + expect(headers['sentry-trace']).toBeUndefined(); |
| 23 | + }) |
| 24 | + .start() |
| 25 | + .then(SERVER_URL => { |
| 26 | + createRunner(__dirname, 'scenario.ts') |
| 27 | + .withEnv({ SERVER_URL }) |
| 28 | + .expect({ |
| 29 | + transaction: { |
| 30 | + // we're not too concerned with the actual transaction here since this is tested elsewhere |
| 31 | + }, |
| 32 | + }) |
| 33 | + .start(done); |
| 34 | + }); |
44 | 35 | });
|
0 commit comments