create-spy-obj
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

create-spy-obj

Create jasmine spy objects magically

NPM version Build status Downloads

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 ✨

Readme

Keywords

none

Package Sidebar

Install

npm i create-spy-obj

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

3.8 kB

Total Files

5

Last publish

Collaborators

  • kolodny