mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
📚 Add state management and testing guidelines documentation
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
This commit is contained in:
35
docs/guidelines/testing.md
Normal file
35
docs/guidelines/testing.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# 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
|
||||
|
||||
```typescript
|
||||
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');
|
||||
});
|
||||
});
|
||||
```
|
||||
Reference in New Issue
Block a user