GithubHelp home page GithubHelp logo

teammay / factory Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 652 KB

๐Ÿญ Testing made easier with factories for your entities/models.

License: ISC License

TypeScript 99.48% JavaScript 0.52%
factory testing test factories typeorm typescript factory-boy seed seeding fixtures

factory's People

Contributors

adrien-may avatar dependabot[bot] avatar matthieumay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

tbrien

factory's Issues

adapters, monorepo and deps

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.

[Question] how would you see setting attributes that are related to each other?

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!

TypeScript support on `attrs` + show example of 1:N "SubFactory"

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).

LazyAttribute function

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:

  • tests
  • docs
  • implementation
  • profit

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.