We are settings up database fixtures in our Node.js project. This is our evaluation of various fixture libraries:
- https://github.com/freewil/node-fixr
- Doesn't seem too popular (2 stars)
- Last commit was 3 years ago
- https://github.com/petejkim/factory-lady
- Only 7 commmits
- Last commit was 4 years ago
- Uncommented PRs sitting around since 2014
- https://github.com/aexmachina/factory-girl
- Seems much more active
- Latest PR was opened 14 days ago
- 6 months ago on last commit
- Supports adapters for
sequelize
and similar - Issue resolution: 29 days, Open issues: 32%
- Seems much more active
- https://github.com/domasx2/sequelize-fixtures
- Also active
- Issue resolution: 17 days, Open issues: 15%
- https://github.com/city41/node-sql-fixtures
- Too few non-owner issues to trust =/
- Issue resolution: 0 days, Open issues: 0%
- Stats lopsided due to opening/closing own issues
- http://isitmaintained.com/project/city41/node-sql-fixtures
Conclusion:
Going to try out sequelize-fixtures
for now as it is less about generating dynamic data and more about fixtures
Our likely usage will be:
- Define models by key in a JS file (so we can leverage nice integrations like
moment-timezone
with getters/setters) - Use the
loadFixtures
method with_.pick
to retrieve models by key- Will prob need to verify that
Object.keys
of_.pick
object is same as keys (so we prevent tests with typos)
- Will prob need to verify that
- Also define
fixtures.DEFAULT_FIXTURES
for easy reference in loader
Also I need to use inserted records in my test, exporting them in array then reading them index wise in test doesn't sound nice way.