Code Monkey home page Code Monkey logo

teddymocks's People

Contributors

mbraude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

teddymocks's Issues

Mocking Interfaces

It would be a nice convenient method to create mocks interfaces the same way, one can do it for classes.

Currently I have to introduce some class in my tests, to pass it to the Stub constructor, because it can't handle no-constructor-types:

    class MyMockingInterfaceClass implements MyInterface {
        someMethod() {throw "method should be replaced by mock"}
    }

This are only 3 lines for this simple example, but becomes really nasty for bigger interfaces.

npm module

Hi,

making TeddyMocks available as npm module would be nice, for a fluent integration into standard workflows.

Errors when compiling TeddyMocks.ts

When executing the typescript compiler to TeddyMocks.ts I get the following errors:

>> test/spec/TeddyMocks/TeddyMocks.ts(160,70): error TS2496: The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.
>> test/spec/TeddyMocks/TeddyMocks.ts(177,40): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
>> test/spec/TeddyMocks/TeddyMocks.ts(214,41): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
>> test/spec/TeddyMocks/TeddyMocks.ts(297,27): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
>> test/spec/TeddyMocks/TeddyMocks.ts(313,23): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.
>> test/spec/TeddyMocks/TeddyMocks.ts(317,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode.

Does it call the original methods?

First, thanks for publishing it!
I'm having problems suppressing calls to original's type methods, maybe it's a misunderstanding of how teddymocks works.

What I expected was: When I mock type T with

var mock = new TeddyMocks.Stub<MyType>(MyType);

I thought I could pass mock.object to any object which requires an instance of MyType. When this object calls any methods on MyType, they do nothing per default and I can "add" behaviour to the mock via

mock.stubs(...

What I see is that when the object calls a method from MyType (using mock.object) this leads to the call of the original method of MyType, somehow defeating the purpose of mocking. I'm sure I'm using it wrong or I overlooked something.

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.