Fix Jest mocks for CI: add virtual: true for optional packages

@polkadot/api and @pezkuwi/* packages are not installed in CI,
so jest.mock needs virtual: true to allow mocking without the
actual module being present.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-18 03:30:47 +03:00
parent 1a47363938
commit 6c6aa2883f
+5 -5
View File
@@ -104,7 +104,7 @@ jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock') require('@react-native-async-storage/async-storage/jest/async-storage-mock')
); );
// Mock Polkadot.js // Mock Polkadot.js (virtual: true because package may not be installed in CI)
jest.mock('@polkadot/api', () => ({ jest.mock('@polkadot/api', () => ({
ApiPromise: { ApiPromise: {
create: jest.fn(() => create: jest.fn(() =>
@@ -118,7 +118,7 @@ jest.mock('@polkadot/api', () => ({
), ),
}, },
WsProvider: jest.fn(), WsProvider: jest.fn(),
})); }), { virtual: true });
// Mock @pezkuwi packages (aliases for @polkadot packages) // Mock @pezkuwi packages (aliases for @polkadot packages)
jest.mock('@pezkuwi/api', () => ({ jest.mock('@pezkuwi/api', () => ({
@@ -150,7 +150,7 @@ jest.mock('@pezkuwi/api', () => ({
), ),
}, },
WsProvider: jest.fn(), WsProvider: jest.fn(),
})); }), { virtual: true });
jest.mock('@pezkuwi/keyring', () => ({ jest.mock('@pezkuwi/keyring', () => ({
Keyring: jest.fn().mockImplementation(() => ({ Keyring: jest.fn().mockImplementation(() => ({
@@ -180,13 +180,13 @@ jest.mock('@pezkuwi/keyring', () => ({
verify: jest.fn(), verify: jest.fn(),
})), })),
})), })),
})); }), { virtual: true });
jest.mock('@pezkuwi/util-crypto', () => ({ jest.mock('@pezkuwi/util-crypto', () => ({
cryptoWaitReady: jest.fn(() => Promise.resolve(true)), cryptoWaitReady: jest.fn(() => Promise.resolve(true)),
mnemonicGenerate: jest.fn(() => 'test test test test test test test test test test test junk'), mnemonicGenerate: jest.fn(() => 'test test test test test test test test test test test junk'),
mnemonicValidate: jest.fn(() => true), mnemonicValidate: jest.fn(() => true),
})); }), { virtual: true });
// Mock Supabase // Mock Supabase
jest.mock('./src/lib/supabase', () => ({ jest.mock('./src/lib/supabase', () => ({