Comments (4)
that would be a killer feature actually, no mocking libs have that
https://github.com/jcteague/autofixturejs - C# lib for that
from factory.ts.
+1 I actually thought this would be supported but upon trying it found out it isn't.
from factory.ts.
Sorry for the long lag on replying to this, but I don't think that's possible with Typescript. At least, not if Foo
might be an interface
or a type
. You can't write a function which takes a generic type and then iterates over its keys or knows what type the values are. Essentially factory.ts cannot introspect/reflect on the generic you use.
Basically for factory.ts the type inference is used to make it easy to specify your factory builder, but you still need to specify it. You could use random generators for each property, e.g.
Factory.makeFactory<Foo>({
bar: randomString(), // (number?) => string
baz: randomNumber(), // (number?) => string
})
from factory.ts.
as per comment above, I don't think you can really build this in TS. But you can specify factories that return random data.
from factory.ts.
Related Issues (20)
- How to randomize buildList results HOT 5
- [Feature request]: makeFactory accepts function parameter HOT 3
- [feature proposal] Allow to specify factory as field default value of another factory HOT 1
- Use value from another field HOT 5
- Current state of the library HOT 2
- Node version bump causes install to fail HOT 2
- Can't use Factory.each to custimize value of build HOT 1
- Derivation using the existing value HOT 2
- Feature request: `create` and `createList`
- Feature request: `resetAllSequenceNumbers`
- Feature request: pass to makeFactory function that returns Builder instead object Builder HOT 1
- This repo does not seem maintained anymore HOT 2
- Combine factories with optional field HOT 3
- Pipelines as generators HOT 1
- Question: How to create a factory outputs tuples? HOT 1
- Failed to parse source maps HOT 1
- How to randomise nested object key in `buildList` HOT 1
- Default merging of objects within factories?
- Possible to allow "transient" values? HOT 1
- Overriding string values with objects, gives an object with string characters as object keys
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 factory.ts.