Skip to content

Commit a3581fa

Browse files
committed
feat(logger): fix failing tests
1 parent 522abd7 commit a3581fa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

identity/__tests__/credentials.test.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
NullifierGenerator,
1313
} from "../src/nullifierGenerators";
1414
import { humanNetworkOprf } from "../src/humanNetworkOprf";
15+
import { logger } from "../src/logger";
1516

1617
// ---- original DIDKit lib
1718
import * as OriginalDIDKit from "@spruceid/didkit-wasm-node";
@@ -39,6 +40,15 @@ jest.mock("../src/humanNetworkOprf", () => ({
3940
initMishti: jest.fn(),
4041
}));
4142

43+
jest.mock("../src/logger", () => ({
44+
logger: {
45+
error: jest.fn(),
46+
debug: jest.fn(),
47+
info: jest.fn(),
48+
warn: jest.fn(),
49+
},
50+
}));
51+
4252
const mockIssuerKey = generateEIP712PairJWK();
4353

4454
// Set up nullifier generators
@@ -466,7 +476,7 @@ describe("issueNullifiableCredential with ignorable errors", () => {
466476
})
467477
).rejects.toThrow("Unable to generate nullifiers");
468478

469-
expect(console.error).toHaveBeenCalled();
479+
expect(logger.error).toHaveBeenCalled();
470480
});
471481

472482
it("handles mix of successful, ignorable, and unexpected errors", async () => {
@@ -499,7 +509,7 @@ describe("issueNullifiableCredential with ignorable errors", () => {
499509
})
500510
).rejects.toThrow("Unable to generate nullifiers");
501511

502-
expect(console.error).toHaveBeenCalled();
512+
expect(logger.error).toHaveBeenCalled();
503513
});
504514
});
505515
});

identity/src/credentials.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const getNullifiers = async ({
138138
.filter((result) => !(result.reason instanceof IgnorableNullifierGeneratorError));
139139

140140
if (unexpectedErrors.length > 0) {
141-
logger.error("Unexpected errors generating nullifiers", unexpectedErrors); // eslint-disable-line no-console
141+
logger.error("Unexpected errors generating nullifiers", unexpectedErrors);
142142
throw new Error("Unable to generate nullifiers");
143143
}
144144

0 commit comments

Comments
 (0)