Skip to content

Service File Prompt

Use the following prompt to generate the unit test for the service file.

javascript
Unit Test For Class: SampleService (extends BaseService).
Write comprehensive unit tests using Jest for all existing methods in the service layer. Ensure that the service's methods are tested in isolation from the controller and other dependencies using mock objects. Remember all existing methods in active service.

## Import
- Import required modules – Import the necessary controller, services, and helpers for the specific service.

## Mock Dependencies
- Use jest.mock to mock services and helper functions related to the new service.
- Repository Layer (mandatory) : The repository methods will be mocked, as we don't want to interact with the real database in unit tests for services.
- Other dependencies (optional) : Mock any other dependencies used by the service if used in the service like base service, redis, graphql, configuration, logging.

## Test Scenario
- Test all the methods in the service layer.
- Test the methods in the service layer should not have any side effects.
- Test the methods in the service layer should not interact with the controller or other dependencies.
- Test the methods in the service layer should not interact with the database.