Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: TypeError: Model is not a constructor #133

Open
k-m-a-c opened this issue Jul 17, 2018 · 0 comments
Open

Comments

@k-m-a-c
Copy link

k-m-a-c commented Jul 17, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant