atp-sdk
Version:
Official TypeScript SDK for Agent Trust Protocol™ - Build secure, verifiable, and trustworthy applications with decentralized identity, verifiable credentials, payment protocols (AP2/ACP), and robust access control
55 lines • 1.52 kB
JavaScript
/**
* Jest test setup for ATP™ SDK
*/
import { jest } from '@jest/globals';
// Mock WebSocket for Node.js environment
global.WebSocket = jest.fn(() => ({
readyState: 1,
send: jest.fn(),
close: jest.fn(),
on: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn()
}));
// Mock fetch for Node.js environment
global.fetch = jest.fn();
// Mock WebCrypto API for Node.js environment
import { webcrypto } from 'crypto';
global.crypto = {
...webcrypto,
getRandomValues: (buffer) => {
const bytes = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
return webcrypto.getRandomValues(bytes);
}
};
// Mock performance API
global.performance = {
now: jest.fn(() => Date.now()),
mark: jest.fn(),
measure: jest.fn(),
getEntriesByName: jest.fn(() => []),
getEntriesByType: jest.fn(() => []),
clearMarks: jest.fn(),
clearMeasures: jest.fn()
};
// Mock AbortSignal
global.AbortSignal = {
timeout: jest.fn((delay) => {
const controller = new AbortController();
setTimeout(() => controller.abort(), delay);
return controller.signal;
})
};
// Reset all mocks before each test
beforeEach(() => {
jest.clearAllMocks();
});
// Global test timeout
jest.setTimeout(30000);
// Add at least one test to avoid empty test suite error
describe('Setup', () => {
it('should initialize test environment', () => {
expect(true).toBe(true);
});
});
//# sourceMappingURL=setup.js.map