|
1 | 1 | import { cleanupChildProcesses, createRunner } from '../../../utils/runner';
|
| 2 | +import { createTestServer } from '../../../utils/server'; |
2 | 3 |
|
3 | 4 | describe('httpIntegration', () => {
|
4 | 5 | afterAll(() => {
|
@@ -130,43 +131,55 @@ describe('httpIntegration', () => {
|
130 | 131 |
|
131 | 132 | describe("doesn't create child spans or breadcrumbs for outgoing requests ignored via `ignoreOutgoingRequests`", () => {
|
132 | 133 | test('via the url param', done => {
|
133 |
| - const runner = createRunner(__dirname, 'server-ignoreOutgoingRequests.js') |
134 |
| - .expect({ |
135 |
| - transaction: event => { |
136 |
| - expect(event.transaction).toBe('GET /testUrl'); |
137 |
| - |
138 |
| - const requestSpans = event.spans?.filter(span => span.op === 'http.client'); |
139 |
| - expect(requestSpans).toHaveLength(1); |
140 |
| - expect(requestSpans![0]?.description).toBe('GET https://example.com/pass'); |
141 |
| - |
142 |
| - const breadcrumbs = event.breadcrumbs?.filter(b => b.category === 'http'); |
143 |
| - expect(breadcrumbs).toHaveLength(1); |
144 |
| - expect(breadcrumbs![0]?.data?.url).toEqual('https://example.com/pass'); |
145 |
| - }, |
146 |
| - }) |
147 |
| - .start(done); |
148 |
| - |
149 |
| - runner.makeRequest('get', '/testUrl'); |
| 134 | + createTestServer(done) |
| 135 | + .get('/blockUrl', () => {}, 200) |
| 136 | + .get('/pass', () => {}, 200) |
| 137 | + .start() |
| 138 | + .then(([SERVER_URL, closeTestServer]) => { |
| 139 | + createRunner(__dirname, 'server-ignoreOutgoingRequests.js') |
| 140 | + .withEnv({ SERVER_URL }) |
| 141 | + .expect({ |
| 142 | + transaction: event => { |
| 143 | + expect(event.transaction).toBe('GET /testUrl'); |
| 144 | + |
| 145 | + const requestSpans = event.spans?.filter(span => span.op === 'http.client'); |
| 146 | + expect(requestSpans).toHaveLength(1); |
| 147 | + expect(requestSpans![0]?.description).toBe(`GET ${SERVER_URL}/pass`); |
| 148 | + |
| 149 | + const breadcrumbs = event.breadcrumbs?.filter(b => b.category === 'http'); |
| 150 | + expect(breadcrumbs).toHaveLength(1); |
| 151 | + expect(breadcrumbs![0]?.data?.url).toEqual(`${SERVER_URL}/pass`); |
| 152 | + }, |
| 153 | + }) |
| 154 | + .start(closeTestServer) |
| 155 | + .makeRequest('get', '/testUrl'); |
| 156 | + }); |
150 | 157 | });
|
151 | 158 |
|
152 | 159 | test('via the request param', done => {
|
153 |
| - const runner = createRunner(__dirname, 'server-ignoreOutgoingRequests.js') |
154 |
| - .expect({ |
155 |
| - transaction: event => { |
156 |
| - expect(event.transaction).toBe('GET /testRequest'); |
157 |
| - |
158 |
| - const requestSpans = event.spans?.filter(span => span.op === 'http.client'); |
159 |
| - expect(requestSpans).toHaveLength(1); |
160 |
| - expect(requestSpans![0]?.description).toBe('GET https://example.com/pass'); |
161 |
| - |
162 |
| - const breadcrumbs = event.breadcrumbs?.filter(b => b.category === 'http'); |
163 |
| - expect(breadcrumbs).toHaveLength(1); |
164 |
| - expect(breadcrumbs![0]?.data?.url).toEqual('https://example.com/pass'); |
165 |
| - }, |
166 |
| - }) |
167 |
| - .start(done); |
168 |
| - |
169 |
| - runner.makeRequest('get', '/testRequest'); |
| 160 | + createTestServer(done) |
| 161 | + .get('/blockUrl', () => {}, 200) |
| 162 | + .get('/pass', () => {}, 200) |
| 163 | + .start() |
| 164 | + .then(([SERVER_URL, closeTestServer]) => { |
| 165 | + createRunner(__dirname, 'server-ignoreOutgoingRequests.js') |
| 166 | + .withEnv({ SERVER_URL }) |
| 167 | + .expect({ |
| 168 | + transaction: event => { |
| 169 | + expect(event.transaction).toBe('GET /testRequest'); |
| 170 | + |
| 171 | + const requestSpans = event.spans?.filter(span => span.op === 'http.client'); |
| 172 | + expect(requestSpans).toHaveLength(1); |
| 173 | + expect(requestSpans![0]?.description).toBe(`GET ${SERVER_URL}/pass`); |
| 174 | + |
| 175 | + const breadcrumbs = event.breadcrumbs?.filter(b => b.category === 'http'); |
| 176 | + expect(breadcrumbs).toHaveLength(1); |
| 177 | + expect(breadcrumbs![0]?.data?.url).toEqual(`${SERVER_URL}/pass`); |
| 178 | + }, |
| 179 | + }) |
| 180 | + .start(closeTestServer) |
| 181 | + .makeRequest('get', '/testRequest'); |
| 182 | + }); |
170 | 183 | });
|
171 | 184 | });
|
172 | 185 | });
|
0 commit comments