# Testing Instructions ## Framework and Tools - Use **Jest** as the testing framework. - For unit tests, utilize **Spectator** to simplify Angular component testing. ## Guidelines 1. **Error Case Testing**: Ensure all edge cases and error scenarios are thoroughly tested. 2. **Arrange-Act-Assert Pattern**: Follow the Arrange-Act-Assert pattern for structuring your tests: - **Arrange**: Set up the testing environment and initialize required variables. - **Act**: Execute the functionality being tested. - **Assert**: Verify the expected outcomes. ## Best Practices - Write clear and descriptive test names. - Ensure tests are isolated and do not depend on each other. - Mock external dependencies to avoid side effects. - Aim for high code coverage without compromising test quality. ## Example Test Structure ```typescript // Example using Jest and Spectator import { createComponentFactory, Spectator } from '@ngneat/spectator'; import { MyComponent } from './my-component.component'; describe('MyComponent', () => { let spectator: Spectator; const createComponent = createComponentFactory(MyComponent); beforeEach(() => { spectator = createComponent(); }); it('should display the correct title', () => { // Arrange const expectedTitle = 'Hello World'; // Act spectator.component.title = expectedTitle; spectator.detectChanges(); // Assert expect(spectator.query('h1')).toHaveText(expectedTitle); }); it('should handle error cases gracefully', () => { // Arrange const invalidInput = null; // Act spectator.component.input = invalidInput; // Assert expect(() => spectator.component.processInput()).toThrowError('Invalid input'); }); }); ``` ## Additional Resources - [Jest Documentation](https://jestjs.io/docs/getting-started) - [Spectator Documentation](https://ngneat.github.io/spectator/)