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

TypeError: Utils.stack(...).getFileName is not a function #35

Closed
KMNowak opened this issue Nov 20, 2017 · 3 comments
Closed

TypeError: Utils.stack(...).getFileName is not a function #35

KMNowak opened this issue Nov 20, 2017 · 3 comments
Assignees

Comments

@KMNowak
Copy link

KMNowak commented Nov 20, 2017

Hello everyone!

I started using your library, because seems to be extremely useful in my project. Unfortunately, while running jest test, an error occurs:

TypeError: Utils.stack(...).getFileName is not a function
at Sequelize.Object.<anonymous>.Sequelize.import (node_modules/sequelize-mock/src/sequelize.js:332:44)

It points to line:

var callLoc = path.dirname(Utils.stack().getFileName());

Reference to original sequelize models looks like:

this.DB.import(`./{modelName}`)

All import paths were overriden by $overrideImport method in many ways, but none succeeded.

What could be the reason of that behaviour?

Thank you in advance for any response.

@LoveAndCoding
Copy link
Contributor

Should be fixed in v0.10.1. Try updating and let me know if you still have issues

@KMNowak
Copy link
Author

KMNowak commented Nov 21, 2017

I really appreciate such quick help!
It fixed pervious case, but another one occured:

When exporting models by

export default (DB:Sequelize, Datatypes: Datatypes) => sequelizeMock.define(...)

line:

this.importCache[importPath] = require(importPath).default(this, DataTypes);

in place of

this.importCache[importPath] = require(importPath)(this, DataTypes);

fixes issue

require(...) is not a function`

I hope you will find it helpful.

@LoveAndCoding
Copy link
Contributor

Ah I missed support for export default in their code base. I will try to add support for that when I get a chance. I've added a separate bug for that as issue #36

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

No branches or pull requests

2 participants