-
Notifications
You must be signed in to change notification settings - Fork 113
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
Browser support #70
Browser support #70
Conversation
…d without a value (e.g. `expect(req).to.have.param('orderby')`)
…hai-http that runs in web browsers
…that are specific to Node or browsers
Some really good work there @BigstickCarpet. All of the code looks really good and thank you for the nicely separated commits. The only thing that's missing from this is documentation 😉. Could you please update |
lol. Glad you like the changes so much! The reason I didn't update the |
…ain functionality that is not supported in browsers, or which behaves differently.
@keithamus - Docs updated, as requested. |
Wonderful work @BigstickCarpet 😸 |
Awesome! Glad to help out. Do you know when this version will be published to npm? I'm giving a presentation on REST API testing on Wednesday, and I'd love to demo Chai HTTP in a browser |
Cooool! I'll try to cut a release in the next hour or two. |
👍 Thanks! All PRs should go this smoothly :) |
I agree 😜 |
btw... how does this page get updated to get rid of the "browser not supported" message? |
@BigstickCarpet... bit of a long story that one. We're currently in the process of porting the site to gh-pages (see https://chaijs.github.io/chai-docs/), and with it automating the tagging of plugins (see chaijs/chaijs.github.io#34). Long story short though - don't worry about it - #72 this will fix it for the new site 😄 |
👍 Roger that. Sounds like you're on top of things |
btw @keithamus - Just in case you haven't see this: Chai-HTTP's killer feature: browser testing |
Great stuff! Thanks @BigstickCarpet 😄. Watched your video at Austin API, was great stuff 👍 |
This PR adds browser support (issue #68). All tests pass in Node and in all modern web browsers (Chrome, Firefox, Safari, Opera, Internet Explorer, and Edge)
make
ormake bundle
will create a browser-compatible bundle, via browserifynpm start
will build the browser bundle and then start an HTTP server at http://localhost:8080, so you can run the tests in your web browser(s).Most of the existing tests worked fine in browsers without any changes. A few of the assertion tests required minor changes to use SuperAgent's properties/methods instead of Node's properties/methods. The SuperAgent properties/methods work in Node and web browsers.
The
TestAgent
class required some minor changes due to the different way that cookies are handled in web browsers.I added some new tests to
request.js
that use HttpBin.org to test response headers, cookies, etc. These tests are needed when testing in web browsers, sincehttp.createServer()
is unavailable. But they also work in Node, so they serve as a good sanity check to make sure things work consistently across both platforms.Anyway... here are the tests running in a bunch of browsers: