Open mildfuzz opened 8 years ago
Hi, to further debug this with you we need some more context:
Thanks
It's in a Jasmine spec, not in algolia module.
I am struggling to pin what exactly is causing it, but am I wrong in thinking that all requests should be expected, and I do not need to register a request ahead of time.
You need to register to request ahead of time, this is done so that you explicitly expect for requests rather than having some requests being done while you were not listening.
The examples on the front page make it appear that we do not need to specify a path or a domain, just that we want to intercept (fauxJax.install) On Wed, 22 Jun 2016 at 14:39, Vincent Voyer notifications@github.com wrote:
You need to register to request ahead of time, this is done so that you explicitly expect for requests rather than having some requests being done while you were not listening.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/algolia/faux-jax/issues/19#issuecomment-227746310, or mute the thread https://github.com/notifications/unsubscribe/AAMAYWvSFXBD7PBdxvgugA1A93ye5vGyks5qOTscgaJpZM4I7rcL .
Yes once you install, everything is captured
so assuming I have done that before any tests run (which I have), what other conditions could lead to this errror being triggered?
what other conditions could lead to this errror being triggered?
Well it means somewhere you got a request you were not listening for, for example if you use waitFor(3) and 4 requests are coming, or if you do .once('request') and another one is coming.
Other than that, I don't know, maybe dig inside your code and debug it. Without any reproducing code that's hard to solve, sorry
hmm, not using either of those methods :/
If I comment out line 68 of index.js
//this.emit('error', new Error('faux-jax: received an unexpected request: ' + req.headers.host + req.url));
I get a string of fauxJax.remove is not a function
which makes me think that it is not installed correctly.
If I simply install once (rather than beforeEach
) and don't use remove, then my jasmine spec passes, albeit with a memory leak warning which i did not have before.
Does any of that mean anything to you?
Okay, so that was me being dopey. I was using remove instead of restore.
The first half of that comment still stands. I need to remove that error in order for my tests to pass, which they all do
Sorry I fail to see if you are still having an issue?
My tests pass, but only if I comment out line 68 of the fauxJax index.js
To easily solve this now we need a repo where we can reproduce the problem.
I fixed this issue by disabling the errors. Currently I am building from my own fork, but would prefer to pull back into the project. Is it worth making the errors a config option?
I will accept a PR adding an option like "allowUnexpectedRequests"
I am getting the error
faux-jax: received an unexpected request
It's confusing because the stack is not pointing to any of my code, and as far as I can tell ALL requests should be expected.