-
-
Notifications
You must be signed in to change notification settings - Fork 770
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: Cannot call method 'create' of undefined. When calling sinon.fakeServer #125
Comments
Unfortunately, the
|
You can also do
both will fail if lib structure changes with new update, but this one looks a bit cleaner :) |
When I do that I obtain a new error :
And
leads to :
|
The server isn't really designed to work on node at this point. You can hack it in place the following way, but note that it only fakes XMLHttpRequest, so that has to be somehow defined up front.
|
I forgot to mention that I use it with Brunch Test feature. http://brunch.io/ |
@cjohansen I noticed that there is an issue set for milestone 1.4.0 to make fakeServer override http.request in node. Is this still planned? #21 |
It didn't make it in for 1.4. I honestly don't know when I'll have time to On Wed, Oct 3, 2012 at 1:49 AM, Levi Hackwith [email protected]:
|
Running in Node with the xmlhttprequest module installed and the fake_xml_http_request successfully required, I find the same error as @frankrousseau when executing
I believe this is caused by the Even though In fact, I find that locally removing the |
Here's an additional use case: We use Browserify to build our app so that we can write modules that can be shared between server and the client. For the client app, the tests are run in Karma, a browser environment. So, despite having an environment where fakeServer would work, requiring sinon won't pull in fakeServer, and requiring fakeServer won't setup the right binding to sinon. |
@adborden can you open a separate ticket that describes the issue that you're experiencing? If you feel the issue is relevant to this one, please mention this one and GitHub will create links between them. |
@mroderick fakeServer is still not functioning in a node environment, but I believe vojtechs fix does work. Can you reopen this issue? |
@StephenGrider ok, I'll re-open it. We will have to investigate further |
I have the same problem - sinon.fakeServer == undefined (removing var from fake_server.js didn`t help) |
If I understand the root cause of this issue correctly, this should be resolved as part of the CommonJS-ification of the Sinon internals that is being undertaken as part of the v2.0 release. See #966. |
Verified to be working in the node shell:
|
I`m trying to initialize fakeServer instance while I have sinon required in my env. Here goes my setup:
helper.js
In my spec I call:
my_test.coffee
When I
m executing code
sinon.fakeServerreturns
undefined`. How can I manage to force fake server feature to work?P.S. I
m newbie in the JS testing. Please, don
t judge me:)The text was updated successfully, but these errors were encountered: