@sap_oss/wdio-qmate-service
Version:
[](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[](http
27 lines (21 loc) • 610 B
text/typescript
import { describe, it, vi, beforeEach, afterAll, expect } from "vitest";
import { getUserId } from "../../../src/scripts/stats/getUserId";
vi.mock("os", () => {
return {
homedir: vi.fn().mockImplementation(() => { throw new Error("Home directory not accessible") })
};
});
describe("getUserId - error case", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("should return null if home directory is not accessible", async () => {
// Act
const userId = await getUserId();
// Verify
expect(userId).toBeNull();
});
afterAll(() => {
vi.clearAllMocks();
});
});