- Add GitHub Actions CI workflow with lint, type-check, test, build, and e2e jobs - Configure Jest for unit and integration tests with coverage reporting - Create unit tests for BaseAgent, PlantLineageAgent, and AgentOrchestrator - Add blockchain PlantChain unit tests - Create API integration tests for plants endpoints - Configure Cypress for E2E testing with support files and custom commands - Add E2E tests for home, plant registration, transparency, and vertical farm pages - Set up Prettier for code formatting with configuration - Configure Husky pre-commit hooks with lint-staged - Add commitlint for conventional commit message enforcement - Update package.json with new scripts and dev dependencies This implements Agent 5 (Testing & CI/CD) from the deployment plan.
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
/**
|
|
* Jest Test Setup
|
|
* Global configuration and utilities for all tests
|
|
*/
|
|
|
|
// Extend Jest matchers if needed
|
|
// import '@testing-library/jest-dom';
|
|
|
|
// Mock console methods to reduce noise in tests
|
|
const originalConsole = { ...console };
|
|
|
|
beforeAll(() => {
|
|
// Suppress console.log during tests unless DEBUG is set
|
|
if (!process.env.DEBUG) {
|
|
console.log = jest.fn();
|
|
console.info = jest.fn();
|
|
}
|
|
});
|
|
|
|
afterAll(() => {
|
|
// Restore console
|
|
console.log = originalConsole.log;
|
|
console.info = originalConsole.info;
|
|
});
|
|
|
|
// Global timeout for async operations
|
|
jest.setTimeout(10000);
|
|
|
|
// Clean up after each test
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
// Utility function for creating mock dates
|
|
export function mockDate(date: Date | string): void {
|
|
const mockDateValue = new Date(date);
|
|
jest.spyOn(global, 'Date').mockImplementation(() => mockDateValue as any);
|
|
}
|
|
|
|
// Utility function for waiting in tests
|
|
export function wait(ms: number): Promise<void> {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
}
|
|
|
|
// Utility to create test IDs
|
|
export function createTestId(prefix: string): string {
|
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
}
|