Git Product home page Git Product logo

mikro-resources's People

Contributors

cyriacbr avatar dependabot[bot] avatar tolgap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mikro-resources's Issues

Use with CLI for CI/CD

Hi,

as I am further planning on migrating my projects from TypeORM to MikroORM I noticed another issue I am having right now with seeding:

Before I was using typeorm-seeding (https://github.com/w3tecch/typeorm-seeding) which has a build in CLI to start seeding the DB, which is great for usage in CI/CD pipelines to set up a test database for e2e tests.

Is this somehow possible with this package? I want to keep migrations, seeds and tests seperated as much as possible from the main code.

make().with().oneAndPersist() and make().with().manyAndPersist() do not work

Given these two extra test cases for factory.test.ts:

describe(`Factory`, () => {
  let orm: MikroORM;
  let factory: FixtureFactory;

  beforeAll(async () => {
    orm = await MikroORM.init(ormConfig as any);
    await orm.getSchemaGenerator().dropSchema();
    await orm.getSchemaGenerator().createSchema();
    factory = new FixtureFactory(orm);
  });

  afterAll(() => orm.close());

  it(`make().with().oneAndPersist()`, async () => {
    const result = factory.make(Author).with({ age: 30 });
    expect(result.oneAndPersist).toBeInstanceOf(Function);
  });

  it(`make().with().manyAndPersist()`, async () => {
    const result = factory.make(Author).with({ age: 30 });
    expect(result.manyAndPersist).toBeInstanceOf(Function);
  });
})

Results in the following output:

  ● Factory › make().with().oneAndPersist()

    expect(received).toBeInstanceOf(expected)

    Expected constructor: Function

    Received value has no prototype
    Received value: undefined

      58 |   it(`make().with().oneAndPersist()`, async () => {
      59 |     const result = factory.make(Author).with({ age: 30 });
    > 60 |     expect(result.oneAndPersist).toBeInstanceOf(Function);
         |                                  ^
      61 |   })
      62 |

      at test/factory.test.ts:60:34
      at step (node_modules/tslib/tslib.js:143:27)
      at Object.next (node_modules/tslib/tslib.js:124:57)
      at node_modules/tslib/tslib.js:117:75
      at Object.__awaiter (node_modules/tslib/tslib.js:113:16)
      at Object.<anonymous> (test/factory.test.ts:58:39)

  ● Factory › make().with().manyAndPersist()

    expect(received).toBeInstanceOf(expected)

    Expected constructor: Function

    Received value has no prototype
    Received value: undefined

      79 |   it(`make().with().manyAndPersist()`, async () => {
      80 |     const result = factory.make(Author).with({ age: 30 });
    > 81 |     expect(result.manyAndPersist).toBeInstanceOf(Function);
         |                                   ^
      82 |   })
      83 |

      at test/factory.test.ts:81:35
      at step (node_modules/tslib/tslib.js:143:27)
      at Object.next (node_modules/tslib/tslib.js:124:57)
      at node_modules/tslib/tslib.js:117:75
      at Object.__awaiter (node_modules/tslib/tslib.js:113:16)
      at Object.<anonymous> (test/factory.test.ts:79:40)

This package is exactly what I'm looking for, but sadly this pattern does not work. I'm trying to use it for creating seeds.

Use as seeder without using the entity decorators

I want to use a seeder with mikro-orm similar to typeorm-seeder. However, I don't want to pollute my entities with decorators as the seeding is only needed for e2e tests and I want to keep my entities and code base clean of code used for testing purposes.

I also need to be able to generate e.g. 10 Entities with specifically set fields from faker like firstName but without using said decorators in the entities. Is it possible to do e.g. factory.make(Author).with({ firstName: faker.name.firstName() }).manyAndPersist(10); or can the with() mehtod only be used for creating one author?

Support arrays of strings

Currently this is a type error:

  @Property({
    type: () => ArrayType<string>,
    nullable: true,
  })
  @Fixture((faker) => [
    faker.lorem.word(),
    faker.lorem.word(),
    faker.lorem.word(),
  ])
  keywords: string[] = [];

It would be nice if it didn't error.

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.