I do have a class that has 2 overloaded methods.
public static create<M extends Model>(
this: ModelStatic<M>,
values?: M['_creationAttributes'],
options?: CreateOptions<M['_attributes']>
): Promise<M>;
public static create<M extends Model>(
this: ModelStatic<M>,
values: M['_creationAttributes'],
options: CreateOptions<M['_attributes']> & { returning: false }
): Promise<void>;
in my unit test, I'm trying to use jest.spyOn to mock the first method however jest sees only the one that returns Promise<void>.
const mockInsightCreate = jest.spyOn(Insight, "create");
mockInsightCreate.mockReturnValue(Promise.resolve()); // here I need to return an object of type - Insight
Is there a way to instruct spyOn to pickup the first method that returns Promise<M> ?
import {
Model,
} from "sequelize-typescript";
...
export default class Insight extends Model<Insight> {