-
Notifications
You must be signed in to change notification settings - Fork 26
Allow the consumer DSL to be used from code running in a node context (rather than browser) #17
Conversation
I'm not a JS expert in any way, so my apologies if this sounds stupid. We've just pulled out all the "require" stuff so that it can be used in a framework independent way. Would it not be better to do the require line |
…n int; Fixing code to account for both browser and node.
Which XMLHttpRequest is being required here? I didn't think Node had one? I'm not actually sure if we want to make this change or not. @BenSayers is working modifying the code to work with Node in an async way. See #15 |
@bethesque Christmas and New Years slowed me down a bit but I'm back working on it in my spare time now. Should be finished soon. If you are interested in the progress you can see it on my branch. |
No worries. One thing to note is that the xhr.status is a string within a browser, but is an integer in Node. The code in master now does parseInt(xhr.status, 10) !== 200 to cover both bases. |
Hey Ben, if the mock service doesn't start up because you're a numpty and you've forgotten to bundle install before you run the tests, the run-tests just finishes with a success status code. Do you know if there's a way to fail the tests if waitForServerToStart fails? |
Something funny is up with the ordering of the requests. This is running the tests in the example directory. I had to change the files in example/karma.conf.js to
Then I ran
|
Ok, worked it out, I needed to make the tests do the 'done' callback. They can't be synchronous any more. |
I'm thinking, it's quite tedius to do a DELETE and a POST for each interaction. It would be much simpler to do a a PUT /interactions and do the whole thing in one go. I'll look into that if I have the time. |
When verification fails, is there a way to fail the test in an asynchronous world? In the example, if I take out the code that verifies that the response returned by the mock service is right, but make a wrong call to the mock service, the test should still fail, but it doesn't.
|
@bethesque are these comments intended for my nodejs pull request? |
Ha, yes. I just realised I put them on the wrong one. Will repost. I'm going to close this PR, seeing as yours supersedes it. |
This required a couple of changes: