mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-03-25 09:25:47 +00:00
Fix server status test by properly mocking fs module
- Mock fs.readFile in beforeEach to return valid package.json - Mock fs module with existsSync and accessSync for CLI checks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b640074c33
commit
9295dd1ed0
1 changed files with 10 additions and 0 deletions
|
|
@ -21,6 +21,14 @@ import {
|
|||
vi.mock("../../../src/utils/peekaboo-cli");
|
||||
vi.mock("../../../src/utils/server-status");
|
||||
vi.mock("fs/promises");
|
||||
vi.mock("fs", () => ({
|
||||
existsSync: vi.fn(() => false),
|
||||
accessSync: vi.fn(),
|
||||
constants: {
|
||||
X_OK: 1,
|
||||
W_OK: 2,
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock path and url functions to avoid import.meta.url issues in test environment
|
||||
// jest.mock('url', () => ({ // REMOVED
|
||||
|
|
@ -58,6 +66,8 @@ describe("List Tool", () => {
|
|||
vi.clearAllMocks();
|
||||
// Mock fs.access to always succeed by default
|
||||
mockFsAccess.mockResolvedValue(undefined);
|
||||
// Mock fs.readFile to return a valid package.json
|
||||
mockFsReadFile.mockResolvedValue(JSON.stringify({ version: "1.0.0" }));
|
||||
});
|
||||
|
||||
describe("buildSwiftCliArgs", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue