Skip to content

Instantly share code, notes, and snippets.

@todgru
Last active August 21, 2018 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todgru/cae39592986954bd6ec6c15f104c40e0 to your computer and use it in GitHub Desktop.
Save todgru/cae39592986954bd6ec6c15f104c40e0 to your computer and use it in GitHub Desktop.
TypeError: Cannot read property 'getTableName' of undefined node js, Sequelize, Mockery, Sinon, Ava, stub, stubs, stubbing, mock, mocking, is not a function

TypeError: Cannot read property 'getTableName' of undefined or foo.bar is not a function

I've had this error on numerous occasions. Here are a few things to look for:

  • Check that the table name that is included in the query is spelled correctly, check that is it defined correctly (for sequelize).
  • If you are running tests and using Mockery, check that Mockery is setup correctly. Try removing Mockery and running the test.
  • Check that if you are trying to stub with Sinon, that Mockery isn't ALSO trying to stub out the same object.
  • Example of stubbing with Sinon instead of Mockery: https://gist.github.com/todgru/e439373af2488eefc30ae8bd1fe3864a
@carolcoello
Copy link

  • If referencing a promise with then/catch, remember to call with "return".

@shivasurya
Copy link

This is for future developers who come here for this message.

Kindly check if you have passed right variable name containing Tablename for query or you might have missed it in function arguments or somewhere you left the table name reference from modal.<SAMPLE_TABLE_NAME>

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