Function createSpyObject

  • Creates a new object with jasmine spies for each method in type.

    class Greeter {
    greet(name: string) {
    return `Hello, ${name}!`;
    }
    }

    const spyObject = createSpyObject(Greeter);
    spyObject.greet.and.returnValue("Hello, stub!");
    expect(spyObject.greet("Eric")).toBe("Hello, stub!");
    expectSingleCallAndReset(spyObject.greet, "Eric");

    Type Parameters

    • T

    Parameters

    • type: Type<T>

    Returns jasmine.SpyObj<T>