Skip to content

kolodny/create-spy-obj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 ✨

About

Create jasmine spy objects magically

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published