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

Recent change is breaking our unit tests #18

Closed
ericuldall opened this issue Aug 20, 2019 · 7 comments
Closed

Recent change is breaking our unit tests #18

ericuldall opened this issue Aug 20, 2019 · 7 comments

Comments

@ericuldall
Copy link

The recent change you've made cace9e6
is breaking all of our unit tests that use @sinonjs/commons with the following error:

/srv/node_modules/collections/_map.js:162
            return this.size;
                        ^

TypeError: Method get Map.prototype.size called on incompatible receiver #<Map>
    at Map.get size [as size] (<anonymous>)
    at Map.get [as length] (/srv/node_modules/collections/_map.js:162:25)
    at /srv/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype.js:14:29
    at Array.reduce (<anonymous>)
    at copyPrototypeMethods (/srv/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype.js:7:50)
    at Object.<anonymous> (/srv/node_modules/@sinonjs/commons/lib/prototypes/map.js:5:18)

Is it possible to revert this change? It's being included by other dependencies and full impact is not known at this point.

@ericuldall
Copy link
Author

Testing steps:

npm list | grep sinon

returns @sinonjs/commons is at 1.6.0 and tests are failing

rm -rf node_modules/@sinonjs/commons;
npm install @sinonjs/[email protected]

After that npm test works again.

@mroderick
Copy link
Member

I can sympathise with your challenges of having many tests fail because of a dependency update.

However, cace9e6 is a very unobtrusive change, that shouldn't cause anything to fail.

For the Sinon family of libraries we try our best to avoid clashes with other libraries (which is the motivation for cace9e6), but we can't anticipate that another library would modify the builtin prototypes.

I suspect that the real problem here is that you're using a library that extends the prototypes: https://github.com/montagejs/collections

As a quick fix, you might get lucky with loading collections after @sinonjs/commons has loaded.

For background, I'd recommend reading:

@ericuldall
Copy link
Author

I had a ticket open with collections that I've reopened with a link here. We'll see if they have anything good to contribute here.

Also, if anyone else is having this issue and needs a quick fix for now we've just added this to our top level package:

"@sinonjs/commons": "1.4.0"

Works for now :D

@nickyang07
Copy link

I also have exactly the same issue. For me, it fails jest. I could not enforce @sinonjs/commons to 1.4.0, since jest fake-timer depends on it. Any other solution?

@mroderick
Copy link
Member

I also have exactly the same issue. For me, it fails jest. I could not enforce @sinonjs/commons to 1.4.0, since jest fake-timer depends on it. Any other solution?

Jest and Sinon have been playing well together for years, I'm not sure this is the same issue. Please open a new issue following the issue template and if you can, please provide a runnable example that shows the failure

@cmyugovic
Copy link

I made it work with:
"sinon": "^7.0.0",
"@sinonjs/commons": "1.4.0",
"nise": "1.5.2"

@caub
Copy link

caub commented Apr 27, 2022

What fixes this issue for me if moving require('sinon') up to the top of the file

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

5 participants