create-spy-obj
v0.0.2
Published
Create jasmine spy objects magically
Downloads
1
Readme
create-spy-obj
Create jasmine spy objects magically
Usage
import { createSpyObj } from 'create-spy-obj';
class MyService {
myMethod() {
return 'foo';
}
}
interface MyInterface {
getName(): string;
}
// Use it with a class
const myServiceSpyObj = createSpyObj<MyService>();
myServiceSpyObj.myMethod.and.returnValue('bar');
// Use it with an interface
const myInterfaceSpyObj = createSpyObj<MyInterface>();
myInterfaceSpyObj.getName.and.returnValue('cool');
// Use it with a class without generics (can't do the same with interfaces)
const myServiceSpyObj = createSpyObj(MyService);
myServiceSpyObj.myMethod.and.returnValue('bar');
How it works
✨ Proxy magic ✨