Skip to content

Commit 76e2888

Browse files
authored
test: fix pacote tests (#5767)
1 parent 2cd7a62 commit 76e2888

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lib/definitions/pacote-service.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as tar from "tar";
22
import { IProxySettingsBase } from "../common/declarations";
3+
import { Arborist } from "@npmcli/arborist";
34

45
declare global {
56
interface IPacoteService {
@@ -29,6 +30,11 @@ declare global {
2930
* The path to npm cache
3031
*/
3132
cache?: string;
33+
34+
/**
35+
* Arborist instance to use
36+
*/
37+
Arborist?: Arborist;
3238
}
3339

3440
interface IPacoteManifestOptions extends IPacoteBaseOptions {

test/services/pacote-service.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { NpmConfigService } from "../../lib/services/npm-config-service";
99
import { INpmConfigService } from "../../lib/declarations";
1010
import { IProxySettings } from "../../lib/common/declarations";
1111
import { IInjector } from "../../lib/common/definitions/yok";
12+
import { Arborist } from "@npmcli/arborist";
1213

1314
import * as pacote from "pacote";
1415
import * as tar from "tar";
@@ -48,10 +49,9 @@ const createTestInjector = (opts?: ITestSetup): IInjector => {
4849
testInjector.register("npmConfigService", NpmConfigService);
4950

5051
if (!isNpmConfigSet) {
51-
const npmConfigService: INpmConfigService = testInjector.resolve(
52-
"npmConfigService"
53-
);
54-
defaultPacoteOpts = npmConfigService.getConfig();
52+
const npmConfigService: INpmConfigService =
53+
testInjector.resolve("npmConfigService");
54+
defaultPacoteOpts = { ...npmConfigService.getConfig(), Arborist };
5555
isNpmConfigSet = true;
5656
}
5757

@@ -169,8 +169,7 @@ describe("pacoteService", () => {
169169
expectedPackageName: packageName,
170170
},
171171
{
172-
name:
173-
"with 'cache', passed options and proxy settings when proxy is configured",
172+
name: "with 'cache', passed options and proxy settings when proxy is configured",
174173
manifestOptions,
175174
useProxySettings: true,
176175
expectedPackageName: packageName,
@@ -181,23 +180,20 @@ describe("pacoteService", () => {
181180
expectedPackageName: fullPath,
182181
},
183182
{
184-
name:
185-
"with full path to file, 'cache' and passed options when local path is passed",
183+
name: "with full path to file, 'cache' and passed options when local path is passed",
186184
manifestOptions,
187185
isLocalPackage: true,
188186
expectedPackageName: fullPath,
189187
},
190188
{
191-
name:
192-
"with full path to file, 'cache' and proxy settings when proxy is configured",
189+
name: "with full path to file, 'cache' and proxy settings when proxy is configured",
193190
manifestOptions,
194191
isLocalPackage: true,
195192
useProxySettings: true,
196193
expectedPackageName: fullPath,
197194
},
198195
{
199-
name:
200-
"with full path to file, 'cache', passed options and proxy settings when proxy is configured and local path is passed",
196+
name: "with full path to file, 'cache', passed options and proxy settings when proxy is configured and local path is passed",
201197
manifestOptions,
202198
useProxySettings: true,
203199
isLocalPackage: true,

0 commit comments

Comments
 (0)