Files
ISA-Frontend/docs/guidelines/testing.md
Lorenz Hilpert 3c110efdfa 📚 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
2025-03-31 11:52:17 +02:00

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');
  });
});