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: 'x' is not a function #233

Closed
danruziska opened this issue Apr 26, 2017 · 1 comment
Closed

TypeError: 'x' is not a function #233

danruziska opened this issue Apr 26, 2017 · 1 comment

Comments

@danruziska
Copy link

Hi,

I'm trying to stub a function, returning a fake value and comparing Sinon and Testdouble implementations. So, for the former, I'm using this command:

sinon.stub(catHelper,'getCategoryByPath').callsFake(function(){
  let result = {
	id:1
  };
  return result;
});

It works fine, Sinon can recognize the getCategoryByPath function inside the catHelper object.
I tried to achieve the same result using TestDouble, so I did the same logic:

let catHelperMock = testdouble.replace(catHelper,'getCategoryByPath');    
testdouble.when(catHelperMock.getCategoryByPath('path','')).thenReturn(
{
  id:1
});  

But I'm getting the following error:

TypeError: catHelperMock.getCategoryByPath is not a function

For some reason, it's not recognizing the funciotn. Is there an alternative to achieve the same result?

Thanks!

@searls
Copy link
Member

searls commented Apr 26, 2017

Does catHelperMock.getCategoryByPath actually exist? This example works fine:

https://runkit.com/searls/59011302acedf10011cc8666

@searls searls closed this as completed Apr 26, 2017
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

2 participants