i am trying to unit test a basic service, which just extends typeormservice but gets the error below.

The service was implemented has follows
````typescript
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { TypeOrmCrudService } from '@nestjsx/crud-typeorm';
import { Authorization } from '../models/author.entity';
import { Repository } from 'typeorm';
/**
it turns out any mock repository must declare metadata for the tested service.
(https://github.com/nestjsx/crud/blob/b1f092477fc2fb8945858bf4e39726cd5544c53a/packages/crud-typeorm/src/typeorm-crud.service.ts#L326l). so i tested like these

Hi @avenuer , tried this. Is this still working for you?
It's still working @jakemonton for the base problem of columns, but i have extended it a bit more, a little of the snippets at https://gist.github.com/avenuer/e32320d3eac67e15cb478edd0c1f0c65
Not working for me:
TypeError: Cannot read property 'options' of undefined in constructor of service.
I resolved this kind of error by using the mock class presented by @Darkein here: https://github.com/nestjsx/crud/issues/325#issuecomment-566666542 and adding the metadata property like the following:
public metadata = { connection: { options: { type: null } }, columns: [], relations: [] }
So the final mock class for a repository is like below:
export class MockRepository<T> {
public createQueryBuilder = jest.fn(() => this.queryBuilder);
public manager = { transaction: a => Promise.resolve(a()) };
public metadata = { connection: { options: { type: null } }, columns: [], relations: [] }
public save = jest.fn();
public delete = jest.fn();
public update = jest.fn();
public findOne = jest.fn();
public findOneOrFail = jest.fn();
public find = jest.fn();
public getMany = jest.fn();
public queryBuilder = {
offset: jest.fn().mockReturnThis(),
take: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(),
skip: jest.fn().mockReturnThis(),
limit: jest.fn().mockReturnThis(),
from: jest.fn().mockReturnThis(),
addFrom: jest.fn().mockReturnThis(),
where: jest.fn().mockReturnThis(),
andWhere: jest.fn().mockReturnThis(),
innerJoinAndSelect: jest.fn().mockReturnThis(),
leftJoinAndSelect: jest.fn().mockReturnThis(),
getManyAndCount: jest.fn(),
getMany: jest.fn(),
getOne: jest.fn(),
delete: jest.fn().mockReturnThis(),
execute: jest.fn().mockReturnThis()
};
}
@codeapostle you have test getOne, getMay, createOne, updateOne, replaceOne and deleteOne?
@mkolbusz Man, thank you so much! I was struggling with the - not explicit at all - can't read property "options" of undefined error. Works like a charm. 馃檹
Most helpful comment
I resolved this kind of error by using the mock class presented by @Darkein here: https://github.com/nestjsx/crud/issues/325#issuecomment-566666542 and adding the
metadataproperty like the following:public metadata = { connection: { options: { type: null } }, columns: [], relations: [] }So the final mock class for a repository is like below: