|
1 |
| -import { assertSentryTransaction, getEnvelopeRequest, runServer } from '../../../utils'; |
| 1 | +import { assertSentryTransaction, conditionalTest, getEnvelopeRequest, runServer } from '../../../utils'; |
2 | 2 |
|
3 |
| -test('should instrument GraphQL and Apollo Server.', async () => { |
4 |
| - const url = await runServer(__dirname); |
5 |
| - const envelope = await getEnvelopeRequest(url); |
| 3 | +// Node 10 is not supported by `graphql-js` |
| 4 | +// Ref: https://github.com/graphql/graphql-js/blob/main/package.json |
| 5 | +conditionalTest({ min: 12 })('GraphQL/Apollo Tests', () => { |
| 6 | + test('should instrument GraphQL and Apollo Server.', async () => { |
| 7 | + const url = await runServer(__dirname); |
| 8 | + const envelope = await getEnvelopeRequest(url); |
6 | 9 |
|
7 |
| - expect(envelope).toHaveLength(3); |
| 10 | + expect(envelope).toHaveLength(3); |
8 | 11 |
|
9 |
| - const transaction = envelope[2]; |
10 |
| - const parentSpanId = (transaction as any)?.contexts?.trace?.span_id; |
11 |
| - const graphqlSpanId = (transaction as any)?.spans?.[0].span_id; |
| 12 | + const transaction = envelope[2]; |
| 13 | + const parentSpanId = (transaction as any)?.contexts?.trace?.span_id; |
| 14 | + const graphqlSpanId = (transaction as any)?.spans?.[0].span_id; |
12 | 15 |
|
13 |
| - expect(parentSpanId).toBeDefined(); |
14 |
| - expect(graphqlSpanId).toBeDefined(); |
| 16 | + expect(parentSpanId).toBeDefined(); |
| 17 | + expect(graphqlSpanId).toBeDefined(); |
15 | 18 |
|
16 |
| - assertSentryTransaction(transaction, { |
17 |
| - transaction: 'test_transaction', |
18 |
| - spans: [ |
19 |
| - { |
20 |
| - description: 'execute', |
21 |
| - op: 'db.graphql', |
22 |
| - parent_span_id: parentSpanId, |
23 |
| - }, |
24 |
| - { |
25 |
| - description: 'Query.hello', |
26 |
| - op: 'db.graphql.apollo', |
27 |
| - parent_span_id: graphqlSpanId, |
28 |
| - }, |
29 |
| - ], |
| 19 | + assertSentryTransaction(transaction, { |
| 20 | + transaction: 'test_transaction', |
| 21 | + spans: [ |
| 22 | + { |
| 23 | + description: 'execute', |
| 24 | + op: 'db.graphql', |
| 25 | + parent_span_id: parentSpanId, |
| 26 | + }, |
| 27 | + { |
| 28 | + description: 'Query.hello', |
| 29 | + op: 'db.graphql.apollo', |
| 30 | + parent_span_id: graphqlSpanId, |
| 31 | + }, |
| 32 | + ], |
| 33 | + }); |
30 | 34 | });
|
31 | 35 | });
|
0 commit comments