RobinCK / typeorm-fixtures

:pill: Fixtures loader for typeorm πŸ‡ΊπŸ‡¦
https://robinck.github.io/typeorm-fixtures/
MIT License
566 stars 45 forks source link

For testing purposes and recommendations #86

Closed theo-bittencourt closed 3 years ago

theo-bittencourt commented 4 years ago

Hey. Thank you for this great project!

My main intention with this lib is to load fixtures for automated testing on a Nest project. But after reading the following statement in the README, it has brought me doubts about the purpose of this library:

Although typeorm-fixtures-cli is intended to use as a CLI, you can still load fixtures via APIs in your program.

Loading the fixtures using the CLI means the data will be loaded once for the entire testing suite. One general practice for automated testing is to isolate testing data between testing cases. I'm trying to figure out why programmatically loading is not faced as the first option here. πŸ™ƒ

RobinCK commented 4 years ago

You can use this code: https://github.com/RobinCK/typeorm-fixtures#programmatically-loading-fixtures after each test clear database and repeat load dataset

theo-bittencourt commented 4 years ago

Yep! I'm using that already.

But I'm not sure whether that will continue to work fine for complex relationships. It's been harder to set up the e2e tests as the project grows up because we need to look up for multiple files to track the correct relationships.

Coming from Rails, I'm missing something like FactoryBot to build these data for tests.

I can't figure out yet how Node devs are setting up that data.

moulinraphael commented 4 years ago

Hey I'm missing the same. The way Rails is handling data during tests with FactoryBot is so useful.

Is it possible not to load all the fixtures but only specific ones (and then all recursive references) ?