diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 0a515b9869..e110e72617 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -295,6 +295,11 @@ declare namespace Sinon { * Returns an Array with all callbacks return values in the order they were called, if no error is thrown. */ invokeCallback(...args: any[]): void; + /** + * Set the displayName of the spy or stub. + * @param name + */ + named(name: string): SinonSpy; /** * Returns the nth call. * Accessing individual calls helps with more detailed behavior verification when the spy is called more than once. @@ -530,6 +535,11 @@ declare namespace Sinon { * @param val */ value(val: any): SinonStub; + /** + * Set the displayName of the spy or stub. + * @param name + */ + named(name: string): SinonStub; /** * Similar to callsArg. * Causes the stub to call the first callback it receives with the provided arguments (if any). diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 283d3bb329..502e3f5fd2 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -296,7 +296,7 @@ function testSpy() { const instance = new obj(); let spy = sinon.spy(); - const spyTwo = sinon.spy(); + const spyTwo = sinon.spy().named('spyTwo'); spy = sinon.spy(fn); spy = sinon.spy(instance, 'foo'); @@ -386,7 +386,7 @@ function testStub() { const instance = new obj(); let stub = sinon.stub(); - stub = sinon.stub(instance, 'foo'); + stub = sinon.stub(instance, 'foo').named('namedStub'); const spy: sinon.SinonSpy = stub;