Skip to content

Commit 7d88183

Browse files
committed
conditionally require fetch
1 parent 03fa1dc commit 7d88183

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/node/test/integrations/undici.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Transaction, getCurrentHub } from '@sentry/core';
1+
import type { Transaction } from '@sentry/core';
22
import { Hub, makeMain } from '@sentry/core';
33
import * as http from 'http';
4-
import { fetch } from 'undici';
4+
import type { fetch as FetchType } from 'undici';
55

66
import { NodeClient } from '../../src/client';
77
import { Undici } from '../../src/integrations/undici';
@@ -11,9 +11,18 @@ import { conditionalTest } from '../utils';
1111
const SENTRY_DSN = 'https://[email protected]/0';
1212

1313
let hub: Hub;
14+
let fetch: typeof FetchType;
1415

1516
beforeAll(async () => {
1617
await setupTestServer();
18+
try {
19+
// need to conditionally require `undici` because it's not available in Node 10
20+
// eslint-disable-next-line @typescript-eslint/no-var-requires
21+
fetch = require('undici').fetch;
22+
} catch (e) {
23+
// eslint-disable-next-line no-console
24+
console.warn('Undici integration tests are skipped because undici is not installed.');
25+
}
1726
});
1827

1928
const DEFAULT_OPTIONS = getDefaultNodeClientOptions({

0 commit comments

Comments
 (0)