mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Introduced new documentation files for state management and testing guidelines to enhance developer understanding and best practices. - 📚 **Docs**: Added state management guidelines with local and global state recommendations - 📚 **Docs**: Created testing guidelines including unit testing requirements and best practices - 📚 **Docs**: Updated project structure documentation for clarity
967 B
967 B
Testing Guidelines
Unit Testing Requirements
- Test files should end with
.spec.ts. - Use Spectator for Component, Directive and Service tests.
- Use Jest as the test runner.
- Follow the Arrange-Act-Assert (AAA) pattern in tests.
- Mock external dependencies to isolate the unit under test.
Example Test Structure
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
import { MyComponent } from './my-component.component';
describe('MyComponent', () => {
let spectator: Spectator<MyComponent>;
const createComponent = createComponentFactory(MyComponent);
beforeEach(() => {
spectator = createComponent();
});
it('should create', () => {
expect(spectator.component).toBeTruthy();
});
it('should handle action correctly', () => {
spectator.setInput('inputProp', 'testValue');
spectator.click('button');
expect(spectator.component.outputProp).toBe('expectedValue');
});
});