@bryan-thompson/inspector-assessment-cli 1.35.1 → 1.35.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -238,6 +238,9 @@ function createInvalidConfig(content, filename) {
238
238
  // Test Setup
239
239
  // ============================================================================
240
240
  describe("CLI E2E Integration Tests", () => {
241
+ afterEach(() => {
242
+ jest.clearAllMocks();
243
+ });
241
244
  let vulnerableAvailable = false;
242
245
  let hardenedAvailable = false;
243
246
  beforeAll(async () => {
@@ -13,6 +13,9 @@ import * as path from "path";
13
13
  * without needing to import the actual module (which has side effects)
14
14
  */
15
15
  describe("CLI Argument Parsing Concepts", () => {
16
+ afterEach(() => {
17
+ jest.clearAllMocks();
18
+ });
16
19
  describe("Profile Flag Parsing", () => {
17
20
  const VALID_PROFILES = ["quick", "security", "compliance", "full"];
18
21
  function parseProfile(args) {
@@ -7,6 +7,9 @@ import { describe, it, expect } from "@jest/globals";
7
7
  // Import the barrel/facade module
8
8
  import * as assessmentRunner from "../../lib/assessment-runner/index.js";
9
9
  describe("assessment-runner index exports", () => {
10
+ afterEach(() => {
11
+ jest.clearAllMocks();
12
+ });
10
13
  describe("function exports", () => {
11
14
  it("should export all 6 public functions", () => {
12
15
  expect(typeof assessmentRunner.loadServerConfig).toBe("function");
@@ -39,10 +39,12 @@ const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sd
39
39
  const { connectToServer } = await import("../../lib/assessment-runner/server-connection.js");
40
40
  describe("connectToServer", () => {
41
41
  beforeEach(() => {
42
- jest.clearAllMocks();
43
42
  mockConnect.mockResolvedValue(undefined);
44
43
  mockStdioTransport.stderr.on.mockClear();
45
44
  });
45
+ afterEach(() => {
46
+ jest.clearAllMocks();
47
+ });
46
48
  describe("HTTP transport", () => {
47
49
  it("should create StreamableHTTPClientTransport for transport:http", async () => {
48
50
  const config = {
@@ -34,10 +34,12 @@ describe("loadSourceFiles", () => {
34
34
  const mockReadFileSync = fs.readFileSync;
35
35
  const mockReaddirSync = fs.readdirSync;
36
36
  beforeEach(() => {
37
- jest.clearAllMocks();
38
37
  mockExistsSync.mockReturnValue(false);
39
38
  mockReaddirSync.mockReturnValue([]);
40
39
  });
40
+ afterEach(() => {
41
+ jest.clearAllMocks();
42
+ });
41
43
  describe("README discovery", () => {
42
44
  it("should find README.md in source directory", () => {
43
45
  const sourcePath = "/project";
@@ -15,6 +15,9 @@ describe("createCallToolWrapper", () => {
15
15
  callTool: mockCallTool,
16
16
  };
17
17
  });
18
+ afterEach(() => {
19
+ jest.clearAllMocks();
20
+ });
18
21
  describe("successful tool calls", () => {
19
22
  it("should wrap successful tool response with content array", async () => {
20
23
  mockCallTool.mockResolvedValue({
@@ -12,6 +12,9 @@ import { loadServerConfig, loadSourceFiles, connectToServer, createCallToolWrapp
12
12
  // Test namespace import
13
13
  import * as AssessmentRunner from "../lib/assessment-runner.js";
14
14
  describe("Assessment Runner Facade", () => {
15
+ afterEach(() => {
16
+ jest.clearAllMocks();
17
+ });
15
18
  describe("Function Exports", () => {
16
19
  it("should export loadServerConfig function", () => {
17
20
  expect(typeof loadServerConfig).toBe("function");
@@ -11,6 +11,9 @@
11
11
  import { describe, it, expect } from "@jest/globals";
12
12
  import { ScopedListenerConfig } from "../lib/event-config.js";
13
13
  describe("CLI Build Fixes Regression Tests", () => {
14
+ afterEach(() => {
15
+ jest.clearAllMocks();
16
+ });
14
17
  describe("event-config.ts - CLI_DEFAULT_MAX_LISTENERS constant", () => {
15
18
  it("should use local constant instead of cross-workspace import", () => {
16
19
  // Fix: Replaced DEFAULT_PERFORMANCE_CONFIG.eventEmitterMaxListeners
@@ -101,6 +101,9 @@ async function sendMcpRequest(url, method, params = {}, headers = {}) {
101
101
  return { response, data };
102
102
  }
103
103
  describe("HTTP Transport Integration", () => {
104
+ afterEach(() => {
105
+ jest.clearAllMocks();
106
+ });
104
107
  let vulnerableServerAvailable = false;
105
108
  let hardenedServerAvailable = false;
106
109
  beforeAll(async () => {
@@ -7,7 +7,7 @@
7
7
  * Addresses QA requirement: Test that type guards are mutually exclusive
8
8
  * and correctly discriminate between transport types.
9
9
  */
10
- import { describe, it, expect } from "@jest/globals";
10
+ import { jest, describe, it, expect } from "@jest/globals";
11
11
  import { z } from "zod";
12
12
  // Define schemas inline to avoid import issues with client/lib in CLI tests
13
13
  const HttpSseServerConfigSchema = z.object({
@@ -36,6 +36,9 @@ function isStdioConfig(entry) {
36
36
  return "command" in entry && !("url" in entry);
37
37
  }
38
38
  describe("server-configSchemas type guards", () => {
39
+ afterEach(() => {
40
+ jest.clearAllMocks();
41
+ });
39
42
  describe("isHttpSseConfig", () => {
40
43
  it("should return true for HTTP transport config", () => {
41
44
  const config = {
@@ -4,10 +4,13 @@
4
4
  * Tests for formatZodError utility to ensure helpful error messages.
5
5
  * Addresses QA requirement: verify Zod error messages are helpful (not just generic "Invalid").
6
6
  */
7
- import { describe, it, expect } from "@jest/globals";
7
+ import { jest, describe, it, expect } from "@jest/globals";
8
8
  import { z } from "zod";
9
9
  import { formatZodError, formatZodIssue, formatZodErrorIndented, zodErrorToArray, formatUserFriendlyError, formatZodErrorForJson, } from "../../lib/zodErrorFormatter.js";
10
10
  describe("zodErrorFormatter", () => {
11
+ afterEach(() => {
12
+ jest.clearAllMocks();
13
+ });
11
14
  describe("formatZodIssue", () => {
12
15
  it("should format issue with path", () => {
13
16
  const issue = {
@@ -7,6 +7,9 @@
7
7
  import { jest, describe, it, expect } from "@jest/globals";
8
8
  import { ASSESSMENT_PROFILES, PROFILE_METADATA, MODULE_ALIASES, DEPRECATED_MODULES, TIER_1_CORE_SECURITY, TIER_2_COMPLIANCE, TIER_3_CAPABILITY, TIER_4_EXTENDED, ALL_MODULES, resolveModuleNames, getProfileModules, isValidProfileName, getProfileHelpText, mapLegacyConfigToModules, modulesToLegacyConfig, } from "../profiles.js";
9
9
  describe("Profile Definitions", () => {
10
+ afterEach(() => {
11
+ jest.restoreAllMocks();
12
+ });
10
13
  describe("Profile Constants", () => {
11
14
  it("should have four profiles defined", () => {
12
15
  const profiles = Object.keys(ASSESSMENT_PROFILES);
@@ -22,6 +22,9 @@ const __filename = fileURLToPath(import.meta.url);
22
22
  const __dirname = path.dirname(__filename);
23
23
  const projectRoot = path.resolve(__dirname, "../../../.."); // From cli/src/__tests__/security to root
24
24
  describe("Security Pattern Count Consistency", () => {
25
+ afterEach(() => {
26
+ jest.clearAllMocks();
27
+ });
25
28
  describe("CLI assess-security references", () => {
26
29
  it("should use consistent pattern count in assess-security.ts", () => {
27
30
  const filePath = path.join(projectRoot, "cli/src/assess-security.ts");
@@ -9,6 +9,9 @@
9
9
  import { describe, it, expect } from "@jest/globals";
10
10
  import { AssessmentOptionsSchema, safeParseAssessmentOptions, validateAssessmentOptions, } from "../lib/cli-parserSchemas.js";
11
11
  describe("Stage 3 Fix Validation Tests", () => {
12
+ afterEach(() => {
13
+ jest.clearAllMocks();
14
+ });
12
15
  describe("[TEST-001] cli-parserSchemas.ts - stageBVerbose field (FIX-001)", () => {
13
16
  describe("stageBVerbose field validation", () => {
14
17
  it("should accept stageBVerbose with true value (happy path)", () => {
@@ -120,6 +120,9 @@ async function callTool(url, toolName, args) {
120
120
  return data;
121
121
  }
122
122
  describe("Testbed A/B Comparison", () => {
123
+ afterEach(() => {
124
+ jest.clearAllMocks();
125
+ });
123
126
  let bothServersAvailable = false;
124
127
  let vulnerableAvailable = false;
125
128
  let hardenedAvailable = false;
@@ -8,6 +8,9 @@
8
8
  import { describe, it, expect } from "@jest/globals";
9
9
  import { createTransport } from "../transport.js";
10
10
  describe("Transport Creation", () => {
11
+ afterEach(() => {
12
+ jest.clearAllMocks();
13
+ });
11
14
  describe("Input Validation", () => {
12
15
  it("should throw error when URL is missing for HTTP transport", () => {
13
16
  const options = {
@@ -9,6 +9,9 @@
9
9
  import { ZodError } from "zod";
10
10
  import { AssessmentProfileNameSchema, AssessmentModuleNameSchema, ServerConfigSchema, AssessmentOptionsSchema, ValidationResultSchema, validateAssessmentOptions, validateServerConfig, parseAssessmentOptions, safeParseAssessmentOptions, parseModuleNames, safeParseModuleNames, LogLevelSchema, ReportFormatSchema, TransportTypeSchema, ZOD_SCHEMA_VERSION, } from "../cli-parserSchemas.js";
11
11
  describe("cli-parserSchemas", () => {
12
+ afterEach(() => {
13
+ jest.clearAllMocks();
14
+ });
12
15
  describe("Re-exported schemas", () => {
13
16
  test("exports ZOD_SCHEMA_VERSION", () => {
14
17
  expect(ZOD_SCHEMA_VERSION).toBe(1);
@@ -9,6 +9,9 @@
9
9
  import { ZodError } from "zod";
10
10
  import { HttpSseServerConfigSchema, StdioServerConfigSchema, ServerEntrySchema, ClaudeDesktopConfigSchema, StandaloneConfigSchema, ConfigFileSchema, parseConfigFile, safeParseConfigFile, validateServerEntry, isHttpSseConfig, isStdioConfig, TransportTypeSchema, } from "../server-configSchemas.js";
11
11
  describe("server-configSchemas", () => {
12
+ afterEach(() => {
13
+ jest.clearAllMocks();
14
+ });
12
15
  describe("Re-exported schemas", () => {
13
16
  test("exports TransportTypeSchema", () => {
14
17
  expect(TransportTypeSchema.safeParse("stdio").success).toBe(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bryan-thompson/inspector-assessment-cli",
3
- "version": "1.35.1",
3
+ "version": "1.35.3",
4
4
  "description": "CLI for the Enhanced MCP Inspector with assessment capabilities",
5
5
  "license": "MIT",
6
6
  "author": "Bryan Thompson <bryan@triepod.ai>",