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

Package for use in a browser #15

Closed
ForbesLindesay opened this issue Jan 17, 2013 · 13 comments
Closed

Package for use in a browser #15

ForbesLindesay opened this issue Jan 17, 2013 · 13 comments

Comments

@ForbesLindesay
Copy link
Member

Would it be possible to package these tests to be used in a browser? It would be great to be able to check that a library meets the spec if every browser?

@domenic
Copy link
Member

domenic commented Jan 17, 2013

Yes, I'd like to get this working somehow, maybe using zuul. I know @wycats has already done something ad-hoc using browserify in rsvp.js.

@ForbesLindesay
Copy link
Member Author

Zuul isn't really what I had in mind, it just runs them in phantomjs, which pretty much just proves you weren't relying on process.nextTick. I was thinking we could do with generating a browserified package, as a standalone build so you can just use the standard mocha browser test page with this script in the place where you normally call describe etc.

@ForbesLindesay
Copy link
Member Author

I ultimately want something I can integrate with my ci server so I can produce a badge like:

then/all build status

for my promise library

@domenic
Copy link
Member

domenic commented Jan 17, 2013

Zuul runs them on a web server in your web browser after browserifying them, building a mocha.html with the appropriate <script> tags, etc.

If you want something specific to your CI server, you should probably work on making that possible without any extra code on my part.

@ForbesLindesay
Copy link
Member Author

Sorry, I didn't mean to imply I wanted something specific to my CI server, I just meant to suggest something generic that could be easily run directly in a web-browser, so that it would easily adapt to different running environments. I'm also happy to help do some of the work on this and submit a P.R. I just wanted to make sure I wasn't about to re-invent the wheel first.

I saw phantomjs in the list of dependencies and assumed it was just starting a single headless browser, which wouldn't support cross platform testing.

@domenic
Copy link
Member

domenic commented Jan 17, 2013

If run with no --server argument, it runs it through phantomjs instead. See here for a usage:

https://github.com/NobleJS/setImmediate/blob/master/package.json#L23

@wycats
Copy link

wycats commented Jan 17, 2013

I was able to get things working simply by browserifying. I had to use the browser versions of assert.js and mocha.js (mocha uses expressions in require which makes it non-browserifyable).

Our test harness is pretty simple.

We build test-bundle.js thusly:

browserify tests/test-adapter.js \
promises-tests/lib/tests/**/*.js \
promises-tests/node_modules/sinon/lib/{sinon.js,sinon/*.js} > tests/tmp/test-bundle.js

@ForbesLindesay
Copy link
Member Author

Thanks @wycats that's just the sort of thing I had in mind

@domenic
Copy link
Member

domenic commented Feb 6, 2013

I gave this a quick shot with Zuul, but the problem is the adapter file needs to be supplied somehow, so it's not trivial (but probably still easy).

@calvinmetcalf
Copy link
Contributor

I have a fork of this repo that runs in the browser. Of course the changes I made prevent it from running in node.

domenic added a commit that referenced this issue Mar 8, 2014
…ironment"

This reverts commit 67178f3.

See #15. The change introduced didn't actually work around the PhantomJS-sucks problem, and I'm unwilling to go further into the territory of accomodating-broken-browsers. So let's just revert it back to the simpler version. Full discussion over in that issue.
@mgol
Copy link
Contributor

mgol commented Sep 11, 2014

Any news on the issue? We're planning to switch jQuery Deferred's then to be Promises/A+ compliant but we can't run jQuery in Node without buying into a specific window reimplementation and we'd like to avoid it.

@domenic
Copy link
Member

domenic commented Sep 14, 2014

:O
If we're blocking progress on that, I can make time for this. I'm traveling through early October so it'll be tight, and help would be appreciated, but I'll do my best to squeeze some work in.

@domenic
Copy link
Member

domenic commented Sep 19, 2014

Thanks to the heroic work of @calvinmetcalf in #66, this should now be possible using browserify + Mocha. Let me know how well it works for you, @mzgol. (Also interested in hearing from @stefanpenner since RSVP.js has been using a hacked setup for a while.) If we can help with e.g. documentation, a demo project, or similar happy to do so.

Closing for now but will reopen if anything seems deficient.

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

No branches or pull requests

5 participants