Comments (3)
To implement this feature we would have to merge two different mocks.
Any merge functionality will have to check if a field exist into an object. This will cause trigger getters of our internal mock. If the getter is a reference to a mock that has recursion it will cause Maximum call stack.
Feel free to close the issue if you are happy with the conclusion
Example
interface A {
mySelf: A
}
interface B extends A {
bProperty: string;
}
repository.register('A', (function(){
var __mySelf;
return {
get mySelf() { return __mySelf || (__mySelf = repository.get('A')) },
set mySelf(_mySelf) { mySelf= _mySelf}
},
);
}))
repository.register('B', (function(){
var __bProperty;
var mock;
mock = {
get bProperty() { return __bProperty || (__bProperty = '') },
set bProperty(_bProperty) { bProperty = _bProperty }
};
// this will cause the error because property mySelf of A is recursive
return mergeFunctionality(mock, repository.get('A'))
);
}))
from ts-auto-mock.
I have another idea to solve this that won't trigger the getters, let's keep this open at low priority right now
from ts-auto-mock.
@uittorio I still have an idea on how to do it but I think it's not worth it from every angle.
Not worth it because other features are definitely more important.
Not worth it because it doesn't really improve performance.
Not worth it because it will probably affect the performance negatively (in my solution I would trade lines of code for run time).
I'm closing this, if we actually see people having performance issues with this then we can reopen it.
from ts-auto-mock.
Related Issues (20)
- Error on ESM TypeScript project when using ts-node + mocha HOT 1
- Is there a minimum node version requirement for `ts-auto-mock`? HOT 5
- does it support @swc/jest? HOT 1
- ts-auto-mock with isolatedModule in jest config not working
- does it support Vitest ? HOT 1
- Passing a generic type to createMock throws weird error in a wrong place! HOT 3
- Change Automock Default-Values HOT 1
- "ts-auto-mock" is not published error HOT 2
- [Doc improvement] Improve the `ts-jest` configuration in the docs HOT 3
- typescript 4.9.3 deprecation warnings HOT 1
- The requested module 'ts-auto-mock' does not provide an export named 'createMock' HOT 1
- Support Typescript 5 HOT 10
- Type errors with nested mocks after Typescript 5 upgrade HOT 9
- createHydratedMock() should return Required<T> HOT 1
- Overriding functions does not work HOT 2
- Typescript 5.2.2 : TypeError: DeprecationError: 'originalKeywordKind' has been deprecated since v5.0.0 and can no longer be used. HOT 3
- Error when creating mock of enum with negative value since Typescript 5.4 HOT 3
- Forwarding generic leads to ReferenceError HOT 6
- Error in install instructions on Github Pages website HOT 3
- Object attributes are being copied instead of referenced HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-auto-mock.