@@ -8,8 +8,7 @@ import * as _ from "lodash";
88import { EventEmitter } from "events" ;
99import * as fs from "fs" ;
1010import { NpmConfigService } from "../../lib/services/npm-config-service" ;
11- import { INpmConfigService } from "../../lib/declarations" ;
12- import { IProxySettings } from "../../lib/common/declarations" ;
11+ import { IDictionary , IProxySettings } from "../../lib/common/declarations" ;
1312import { IInjector } from "../../lib/common/definitions/yok" ;
1413import { Arborist } from "@npmcli/arborist" ;
1514import * as pacote from "pacote" ;
@@ -20,6 +19,7 @@ use(chaiAsPromised);
2019
2120let defaultPacoteOpts : IPacoteBaseOptions = null ;
2221let isNpmConfigSet = false ;
22+ let npmConfig : IDictionary < any > = null ;
2323const packageName = "testPackage" ;
2424const fullPath = `/Users/username/${ packageName } ` ;
2525const destinationDir = "destinationDir" ;
@@ -49,14 +49,16 @@ interface ITestCase extends ITestSetup {
4949const createTestInjector = ( opts ?: ITestSetup ) : IInjector => {
5050 opts = opts || { } ;
5151 const testInjector = new Yok ( ) ;
52- testInjector . register ( "npmConfigService" , NpmConfigService ) ;
53-
52+ // Each `npm config` read recomputes `before` from `min-release-age`, so
53+ // read it once and share it, keeping expectations comparable.
5454 if ( ! isNpmConfigSet ) {
55- const npmConfigService : INpmConfigService =
56- testInjector . resolve ( "npmConfigService" ) ;
57- defaultPacoteOpts = { ...npmConfigService . getConfig ( ) , Arborist } ;
55+ npmConfig = new NpmConfigService ( ) . getConfig ( ) ;
56+ defaultPacoteOpts = { ...npmConfig , Arborist } ;
5857 isNpmConfigSet = true ;
5958 }
59+ testInjector . register ( "npmConfigService" , {
60+ getConfig : ( ) : IDictionary < any > => ( { ...npmConfig } ) ,
61+ } ) ;
6062
6163 const npmCachePath = defaultPacoteOpts [ "cache" ] ;
6264
0 commit comments