-
-
Notifications
You must be signed in to change notification settings - Fork 771
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 when requiring sinon in React Native 0.32.0 #1143
Comments
Hi, if I should look into this I don't want to be doing more setup than a |
@fatso83 Carl from initial glance it looks like the setTimeout from lolex-src from line 32: var timeoutResult = setTimeout(NOOP, 0); somehow is resolving into a RN setTimeout...and barfs on Date.now() ?? |
@simonsmith can you try with latest RN 0.34-rc0. I see JSTimers.js heavily refactored - maybe the issue is resolved in RN? |
I am experiencing the same issue, with RN 0.34.1 as well.
|
@thormartin91 could you create a repo that makes it possible to reproduce this easily? I am not likely to debug unsupported platforms I am not using just for fun, especially if it's a hassle to reproduce the error :-) |
@thormartin91 if you create this simple repo I will take a look at the issue. |
This might actually be a problem with mocking of a component, hence a constructor being called. I will continue to investigate and report back :) |
I have not managed to solve this issue, so I created a repository to reproduce it: sinon-issue-1143. The exception occurs if you import both |
@thormartin91 - Just FYI, RN is not officially supported by sinon. Here you are talking about JEST + SINON on RN. So it is double not supported. I had not had an issue using sinon by itself with RN so far with the PR that was merged several months ago. I will take a look at your repo to see if there is anything obvious but I would not expect miracle - just to set expectations... |
No problem, @andpor. const mockFunction = jest.fn(() => 'Mock function')
expect(mockFunction).toBeCalled() |
Based on @thormartin91's test case, I was able to create a much reduced test case that shows the error in effect. https://github.com/mroderick/sinon-issue-1143 I have created sinonjs/fake-timers#87 to fix the issue. Once that has been merged and a new version has been published, I think we should publish a new version of Sinon 2.x. Sinon.JS 1.x is locked to |
Related: jsdom/jsdom#1631 |
It won't be necessary to publish a new 2.x pre-release, as the
I'll focus on some more urgent tasks than this. We can re-visit it if there are requests for it, or pull requests that implements it. |
Opened after discussion in #1051 (comment)
2.0.0-pre.2
What did you expect to happen?
I expect it it work in Jest when running tests against React Native
What actually happens
It throws an error when trying to require the
sinon
library:Throws the following error:
JSTimers.js
How to reproduce
Install
react-native
,jest
andsinon
.Add a unit test like the following:
Run
jest
and see the error.I realise it can be a hassle to set RN up so if you'd like a repo with the error present let me know and I'll create one.
Thanks
The text was updated successfully, but these errors were encountered: