import { Test, TestingModule } from '@nestjs/testing'; import { PipelinesService } from './pipelines.service'; import { Pipeline } from './pipeline.entity'; import { getRepositoryToken } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Project } from '../projects/project.entity'; import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; describe('PipelinesService', () => { let service: PipelinesService; let repository: Repository; let pipeline: Pipeline; beforeEach(async () => { pipeline = Object.assign(new Pipeline(), { id: 'test-pipeline', name: 'pipeline', branch: 'master', projectId: 'test-project', project: Object.assign(new Project(), { id: 'test-project', name: 'project', } as Project), } as Pipeline); const module: TestingModule = await Test.createTestingModule({ providers: [ PipelinesService, { provide: getRepositoryToken(Pipeline), useValue: { findOneOrFail: jest.fn().mockImplementation(() => pipeline), }, }, { provide: AmqpConnection, useValue: {}, }, ], }).compile(); service = module.get(PipelinesService); repository = module.get(getRepositoryToken(Pipeline)); }); it('should be defined', () => { expect(service).toBeDefined(); }); });