mbraude / teddymocks Goto Github PK
View Code? Open in Web Editor NEWA simple mock framework for Javascript, written in and optimized for TypeScript development
A simple mock framework for Javascript, written in and optimized for TypeScript development
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.
Hi,
making TeddyMocks available as npm module would be nice, for a fluent integration into standard workflows.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.