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

Problem when library unintentionally tries to mock hasOwnProperty #107

Closed
insightfuls opened this issue Jun 2, 2018 · 2 comments
Closed

Comments

@insightfuls
Copy link
Contributor

This problem is similar to #28. ts-mockito tries to mock hasOwnProperty and fails with this stack trace:

    TypeError: methodStub.hasMatchingInAnyGroup is not a function
        at Mocker.getMethodStub (node_modules/ts-mockito/lib/Mock.js:186:38)
        at Object.hasOwnProperty (node_modules/ts-mockito/lib/Mock.js:118:36)
        at Mocker.createInstanceActionListener (node_modules/ts-mockito/lib/Mock.js:104:27)
        at node_modules/ts-mockito/lib/Mock.js:88:27
        at Array.forEach (<anonymous>)
        at node_modules/ts-mockito/lib/Mock.js:79:66
        at Array.forEach (<anonymous>)
        at Mocker.processProperties (node_modules/ts-mockito/lib/Mock.js:78:58)
        at new Mocker (node_modules/ts-mockito/lib/Mock.js:27:18)
        at Object.mock (node_modules/ts-mockito/lib/ts-mockito.js:25:12)

I encountered this while trying to mock some built-in objects in NW.js. One way to reproduce it in that environment is to:

  1. create a blank NW.js app (an empty HTML page is fine)
  2. use npm to install ts-mockito
  3. start the NW.js app using the SDK/development version of NW.js
  4. right-click the page and choose Inspect which will open the Chromium Devtools
  5. in the console in the DevTools, execute:
mockito = require("ts-mockito");
mockito.mock(nw.Menu);
insightfuls added a commit to insightfuls/ts-mockito that referenced this issue Jun 2, 2018
@kierans
Copy link

kierans commented Jun 3, 2018

👍

@NagRock
Copy link
Owner

NagRock commented Aug 27, 2018

Fixed in 2.3.1
https://github.com/NagRock/ts-mockito/releases/tag/2.3.1

Thanks @insightfuls for contributing!

@NagRock NagRock closed this as completed Aug 27, 2018
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

3 participants