Skip to content

Commit

Permalink
test: increase timeout for npm cli wrapper tests (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Jun 4, 2023
1 parent 69b2f85 commit e384c72
Showing 1 changed file with 70 additions and 52 deletions.
122 changes: 70 additions & 52 deletions src/npm/__tests__/call-npm-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,82 @@ import { describe, it } from "vitest";
import * as errors from "../../errors.js";
import * as subject from "../call-npm-cli.js";

const TIMEOUT = 10_000;

describe.concurrent("callNpmCli", () => {
it("should call npm CLI", async ({ expect }) => {
const result = await subject.callNpmCli("config", ["list"], {
ignoreScripts: true,
environment: {
npm_config_scope: "@cool-scope",
},
});
it(
"should call npm CLI",
async ({ expect }) => {
const result = await subject.callNpmCli("config", ["list"], {
ignoreScripts: true,
environment: {
npm_config_scope: "@cool-scope",
},
});

expect(result).toEqual({
successData: expect.objectContaining({
json: true,
"ignore-scripts": true,
scope: "@cool-scope",
}),
errorCode: undefined,
error: undefined,
});
});
expect(result).toEqual({
successData: expect.objectContaining({
json: true,
"ignore-scripts": true,
scope: "@cool-scope",
}),
errorCode: undefined,
error: undefined,
});
},
TIMEOUT
);

it("should call npm CLI without ignoring scripts", async ({ expect }) => {
const result = await subject.callNpmCli("config", ["list"], {
ignoreScripts: false,
environment: {
npm_config_scope: "@cool-scope",
},
});
it(
"should call npm CLI without ignoring scripts",
async ({ expect }) => {
const result = await subject.callNpmCli("config", ["list"], {
ignoreScripts: false,
environment: {
npm_config_scope: "@cool-scope",
},
});

expect(result).toMatchObject({
successData: expect.objectContaining({ "ignore-scripts": false }),
});
});
expect(result).toMatchObject({
successData: expect.objectContaining({ "ignore-scripts": false }),
});
},
TIMEOUT
);

it("should return undefined if no JSON in output", async ({ expect }) => {
const result = await subject.callNpmCli("config", ["get", "scope"], {
ignoreScripts: true,
environment: {
npm_config_scope: "",
},
});
it(
"should return undefined if no JSON in output",
async ({ expect }) => {
const result = await subject.callNpmCli("config", ["get", "scope"], {
ignoreScripts: true,
environment: {
npm_config_scope: "",
},
});

expect(result).toEqual({
successData: undefined,
errorCode: undefined,
error: undefined,
});
});
expect(result).toEqual({
successData: undefined,
errorCode: undefined,
error: undefined,
});
},
TIMEOUT
);

it("should return error details if error", async ({ expect }) => {
const result = await subject.callNpmCli("config", [], {
ignoreScripts: true,
environment: {},
});
it(
"should return error details if error",
async ({ expect }) => {
const result = await subject.callNpmCli("config", [], {
ignoreScripts: true,
environment: {},
});

expect(result).toEqual({
successData: undefined,
errorCode: "EUSAGE",
error: expect.any(errors.NpmCallError),
});
});
expect(result).toEqual({
successData: undefined,
errorCode: "EUSAGE",
error: expect.any(errors.NpmCallError),
});
},
TIMEOUT
);
});

0 comments on commit e384c72

Please sign in to comment.