factory-girl
factory-girl copied to clipboard
UnhandledPromiseRejectionWarning: TypeError: Model is not a constructor
Hi!
Love the factory-bot
Ruby gem, and recently discovered this package when working on a new Node project.
I'm trying to get my first factory set up and am encountering the following error when trying to build model instances:
(node:87398) UnhandledPromiseRejectionWarning: TypeError: Model is not a constructor
at DefaultAdapter.build (/path/to/project/node_modules/factory-girl/index.js:717:14)
at Factory._callee2$ (/path/to/project/node_modules/factory-girl/index.js:160:33)
at tryCatch (/path/to/project/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/path/to/project/node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as next] (/path/to/project/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/path/to/project/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /path/to/project/almond-be/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
(node:87398) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
The project is using Sequelize and a Postgres database.
The initial factory definition is as follows:
const { factory, SequelizeAdapter } = require('factory-girl');
const Transaction = require('../../models/transaction');
const adapter = new SequelizeAdapter();
factory.setAdapter(adapter);
factory.define('Transaction', Transaction, {
amount: 10.00,
currency: 'CAD',
name: 'Test Subscription Name',
};
Any ideas?