@sap_oss/wdio-qmate-service
Version:
[](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[](http
29 lines (23 loc) • 621 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();
});
});