Skip to content
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

Merged
merged 7 commits into from
Feb 1, 2016
Merged

Browser support #70

merged 7 commits into from
Feb 1, 2016

Conversation

JamesMessinger
Copy link
Member

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 or make bundle will create a browser-compatible bundle, via browserify

npm 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, since http.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:

browser tests

@keithamus
Copy link
Member

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 README.md with some notes about how this works in the browser? I understand the assertion api will be identical - but obviously parts like chai.request(myConnectApp) need to be signalled as something exclusive to node; and it would be good to describe in the readme, which request frameworks are used in which environment (e.g. XHR in the browser). Let me know when you've updated it and I'll be overjoyed to hit the Merge pull request button 😄

@JamesMessinger
Copy link
Member Author

lol. Glad you like the changes so much!

The reason I didn't update the README.md was that I noticed it gets auto-generated by this script. So I wasn't sure if you wanted me editing docs. But yes, I'll be glad to add some docs that spell-out the differences between Node and browser

@JamesMessinger
Copy link
Member Author

@keithamus - Docs updated, as requested.

@keithamus
Copy link
Member

Wonderful work @BigstickCarpet 😸

keithamus added a commit that referenced this pull request Feb 1, 2016
@keithamus keithamus merged commit 3db5545 into chaijs:master Feb 1, 2016
@JamesMessinger
Copy link
Member Author

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

@keithamus
Copy link
Member

Cooool! I'll try to cut a release in the next hour or two.

@JamesMessinger
Copy link
Member Author

👍 Thanks! All PRs should go this smoothly :)

@keithamus
Copy link
Member

I agree 😜

@JamesMessinger
Copy link
Member Author

btw... how does this page get updated to get rid of the "browser not supported" message?

@keithamus
Copy link
Member

@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 😄

@JamesMessinger
Copy link
Member Author

👍 Roger that. Sounds like you're on top of things

@JamesMessinger
Copy link
Member Author

btw @keithamus - Just in case you haven't see this: Chai-HTTP's killer feature: browser testing

@keithamus
Copy link
Member

Great stuff! Thanks @BigstickCarpet 😄. Watched your video at Austin API, was great stuff 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants