Skip to content

Commit 054f233

Browse files
committed
Fix DD_SITE leak from dd-trace in CI
1 parent d655dcb commit 054f233

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

packages/factory/src/helpers/context.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import type { Options, GlobalContext } from '@dd/core/types';
66
import { BUNDLER_VERSIONS } from '@dd/tests/_jest/helpers/constants';
7-
import { cleanEnv } from '@dd/tests/_jest/helpers/env';
87
import { defaultPluginOptions } from '@dd/tests/_jest/helpers/mocks';
98
import { BUNDLERS, runBundlers } from '@dd/tests/_jest/helpers/runBundlers';
109

@@ -13,7 +12,6 @@ describe('Factory Helpers', () => {
1312
const initialContexts: Record<string, GlobalContext> = {};
1413
const buildRoots: Record<string, string> = {};
1514
let workingDir: string;
16-
let restoreEnv: () => void;
1715

1816
beforeAll(async () => {
1917
const pluginConfig: Options = {
@@ -41,15 +39,10 @@ describe('Factory Helpers', () => {
4139
},
4240
};
4341

44-
restoreEnv = cleanEnv();
4542
const result = await runBundlers(pluginConfig);
4643
workingDir = result.workingDir;
4744
});
4845

49-
afterAll(() => {
50-
restoreEnv();
51-
});
52-
5346
describe('getContext', () => {
5447
describe.each(BUNDLERS)('[$name|$version]', ({ name, version }) => {
5548
test('Should have the right initial context.', () => {

packages/tests/src/_jest/setupAfterEnv.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@ jest.mock('async-retry', () => {
2727
});
2828
});
2929

30+
let restoreEnv: () => void;
3031
beforeAll(() => {
3132
const nock = jest.requireActual('nock');
33+
const { cleanEnv } = jest.requireActual('./helpers/env.ts');
3234
// Do not send any HTTP requests.
3335
nock.disableNetConnect();
36+
// Need to clean env to avoid the `DD_SITE` leak from dd-trace in the CI.
37+
restoreEnv = cleanEnv();
3438
});
3539

3640
afterAll(async () => {
3741
// Clean the workingDirs from runBundlers();
3842
const { cleanupEverything } = jest.requireActual('./helpers/runBundlers.ts');
3943
await cleanupEverything();
44+
restoreEnv();
4045
});
4146

4247
// Have a less verbose, console.log output.

packages/tools/src/rollupConfig.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@dd/error-tracking-plugin/sourcemaps/sender';
1818
import { METRICS_API_PATH } from '@dd/metrics-plugin/common/sender';
1919
import { BUNDLER_VERSIONS, KNOWN_ERRORS } from '@dd/tests/_jest/helpers/constants';
20-
import { cleanEnv, getOutDir, prepareWorkingDir } from '@dd/tests/_jest/helpers/env';
20+
import { getOutDir, prepareWorkingDir } from '@dd/tests/_jest/helpers/env';
2121
import {
2222
FAKE_SITE,
2323
easyProjectEntry,
@@ -148,7 +148,6 @@ const getBuiltFiles = () => {
148148
describe('Bundling', () => {
149149
let bundlerVersions: Partial<Record<BundlerName, string>> = {};
150150
let processErrors: string[] = [];
151-
let restoreEnv: () => void;
152151
const pluginConfig = getFullPluginConfig({
153152
logLevel: 'error',
154153
customPlugins: () => [
@@ -202,8 +201,6 @@ describe('Bundling', () => {
202201
}
203202
return actualStderrWrite(err, ...args);
204203
});
205-
206-
restoreEnv = cleanEnv();
207204
});
208205

209206
afterEach(() => {
@@ -214,7 +211,6 @@ describe('Bundling', () => {
214211

215212
afterAll(async () => {
216213
nock.cleanAll();
217-
restoreEnv();
218214
});
219215

220216
const nameSize = Math.max(...BUNDLERS.map((bundler) => bundler.name.length)) + 1;

0 commit comments

Comments
 (0)