File tree Expand file tree Collapse file tree 3 files changed +6
-12
lines changed
Expand file tree Collapse file tree 3 files changed +6
-12
lines changed Original file line number Diff line number Diff line change 44
55import type { Options , GlobalContext } from '@dd/core/types' ;
66import { BUNDLER_VERSIONS } from '@dd/tests/_jest/helpers/constants' ;
7- import { cleanEnv } from '@dd/tests/_jest/helpers/env' ;
87import { defaultPluginOptions } from '@dd/tests/_jest/helpers/mocks' ;
98import { 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.' , ( ) => {
Original file line number Diff line number Diff line change @@ -27,16 +27,21 @@ jest.mock('async-retry', () => {
2727 } ) ;
2828} ) ;
2929
30+ let restoreEnv : ( ) => void ;
3031beforeAll ( ( ) => {
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
3640afterAll ( 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.
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import {
1717} from '@dd/error-tracking-plugin/sourcemaps/sender' ;
1818import { METRICS_API_PATH } from '@dd/metrics-plugin/common/sender' ;
1919import { 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' ;
2121import {
2222 FAKE_SITE ,
2323 easyProjectEntry ,
@@ -148,7 +148,6 @@ const getBuiltFiles = () => {
148148describe ( '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 ;
You can’t perform that action at this time.
0 commit comments