Fix crypto mock in Cache.test.ts to preserve full module

The jest.mock('crypto') was replacing the entire module, causing
@smithy/uuid to fail with "Cannot read properties of undefined
(reading 'bind')" when @backstage/backend-test-utils was imported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
This commit is contained in:
Fredrik Adelöw
2026-03-06 16:14:23 +01:00
parent d9fb094376
commit 7dc54e2267
@@ -24,11 +24,13 @@ import { readFile } from 'node:fs/promises';
import { join as joinPath } from 'node:path';
jest.mock('crypto', () => {
const actual = jest.requireActual('crypto');
const hash = {
update: jest.fn(),
digest: jest.fn().mockReturnValue('test'),
};
return {
...actual,
createHash: jest.fn().mockReturnValue(hash),
};
});