teammay / factory Goto Github PK
View Code? Open in Web Editor NEW๐ญ Testing made easier with factories for your entities/models.
License: ISC License
๐ญ Testing made easier with factories for your entities/models.
License: ISC License
Make deployment easier with actions.
I believe @jorgebodega had some suggestions ?
This code raises a typescript error while it is correctly interpretated. We should accept sequence as a possible input for createMany
await eventsFactory.createMany(10, {
discussion: discussion2,
createdAt: new Sequence((nb: number) => new Date(now - nb * 10000)),
})
The readme mentions one to many relationships, but as far as I can tell the docs don't describe how this would be done.
In all situation's it seems that TS is unhappy with a Promise<MyType[]>
- the promise being the issue.
It would be useful to have examples of One-to-Many, as well as Many-to-Many, and Many-to-One (the inverse).
Apologies if this is a dense question, but in this example I want the name
and code
to be related - e.g. the code
should be the lowercase value of name
- but name
is generated using faker (or chancejs, etc).
export class ChannelFactory extends Factory<Channel> {
entity = Channel;
attrs = {
name: () => `Web-${faker.datatype.number({ min: 1000, max: 9999 })}`,
code: // should be the name .toLowerCase(),
...
};
}
Do you have a suggested pattern in terms of how to handle this situation?
Thanks for the work so far on this tool, seems useful!
So far, typeorm is a dependency of this package and no other adapter is provided.
This won't be a good solution for long if we want new adapters and avoid useless dependencies.
We may decide to remove the typeorm part to a new repo or use a monorepo here and add adapters + dedicated factory's SubClass in different sections.
Right now, we need to try this library a bit before deciding to expand it to other use.
It would be nice to be able to have attrs depending on other attribute, example
attrs = {
"name": new Sequence(n => `Adrien${n}`),
"email": new LazyAttr(incompleteInstance => `${incompleteInstance}@example.com`)
}
Need:
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.