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

enable passing a reference to chai #1

Merged
merged 2 commits into from
Dec 29, 2013
Merged

enable passing a reference to chai #1

merged 2 commits into from
Dec 29, 2013

Conversation

jkroso
Copy link
Contributor

@jkroso jkroso commented Dec 28, 2013

this is so people like me who use a lot of symlinks and
browserify can pass the actual chai instance in

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 45c7018 on load into 2e85c86 on master.

@vesln
Copy link
Contributor

vesln commented Dec 28, 2013

Awesome! Added you as an owner here too, feel free to merge it in.

Now that you mentioned browserify, I'd be more than happy to find out if hydro (and company) works with it. I actually took the effort to setup testling for hydro but for some weird reason it didn't run the tests on anything but ie 7 and there it couldn't really give me any information, and I couldn't spend more time on it this day. I'm pretty sure it works fine with node-testling locally. However, since I'm not really using browserify, I'd be thrilled to figure out how we can test whether it's working fine (automatically) on a daily basis.

@vesln
Copy link
Contributor

vesln commented Dec 28, 2013

In fact, we are having the same problem with Chai.js itself (or used to have at least). cc: @logicalparadox

@jkroso
Copy link
Contributor Author

jkroso commented Dec 28, 2013

I don't actually use browserify either but something which works similarly. The trick is all dependencies need to be statically declared in require calls. And while loa('./dep') is kinda statically determinable in a lot of cases it won't work ATM because its in the too hard basket AFAIK. All of hydro that I have seen should be fine, users will just need to pass some things explicitly like I've done with this plugin.

@vesln
Copy link
Contributor

vesln commented Dec 28, 2013

Interesting, what's the tool that you are using? Would you be interested to improve the Travis build, so it actually bundles hydro with it and checks if it's working fine, by, say, running the tests on phantomjs or even on sauce as it currently does with karma?

@jkroso
Copy link
Contributor Author

jkroso commented Dec 28, 2013

I'm using sourcegraph which I wrote because I hate substacks insistance on streaming everything and I had a couple ideas I wanted to try out but they turned out to be bad ideas. Sure I'll have a crack at it. I'll start with browserify because I haven't look at it since 1.x.

@vesln
Copy link
Contributor

vesln commented Dec 28, 2013

Sweet!

@jkroso
Copy link
Contributor Author

jkroso commented Dec 28, 2013

I don't know much about sourcelabs, karma, or travis so im a bit lost figuring out what's going on. Is there any way to manually run the test suite in a browser?

@vesln
Copy link
Contributor

vesln commented Dec 28, 2013

Yeah, under hydro you can do make test-browser which will start karma and run the tests on Chrome, Firefox, Safari and PhantomJS. I believe if any of these doesn't exist on your computer it will just print a warning but won't fail. The important things to look at are:

In case you want to trigger the tests on SauceLabs from your computer, you would need SauceLabs username & secret. It's free for open source projects so you can sign up freely, if not desired though I can email you the credentials that I use for hydro, but I don't to share them publicly in order to avoid evil people abusing them (they are encrypted for Travis https://github.com/hydrojs/hydro/blob/master/.travis.yml.

Afterwards you do:

$ SAUCE_HYDRO_USERNAME=xxx SAUCE_HYDRO_ACCESS_KEY=xxx make test-sauce

Let me know if this helps, I'd be happy to expand it even further.

@jkroso
Copy link
Contributor Author

jkroso commented Dec 29, 2013

Yea I'm just having problems figuring out exactly what code karma runs. And how it knows the test results?

jkroso added a commit that referenced this pull request Dec 29, 2013
enable passing a reference to chai
@jkroso jkroso merged commit db5b5f7 into master Dec 29, 2013
@jkroso jkroso deleted the load branch December 29, 2013 12:23
@jkroso
Copy link
Contributor Author

jkroso commented Dec 29, 2013

Actually never mind I've more or less figured it out. It'll take a bit of time but I should be able to get karma to run a browserified build

@vesln
Copy link
Contributor

vesln commented Dec 29, 2013

Karma seems like a lot of magic, but once you figure out how it does it - it actually makes sense. What it does is fire up a node server, include the file that you've specified in the config and then pipe the output from the browsers to the console via web sockets. In order to tell Karma the results of the tests we needed to build a custom formatter which is basically a proxy between hydro and karma itself (https://github.com/hydrojs/karma-hydro/blob/master/adapter.js).

karma-hydro allows you to supply a custom path to hydro (https://github.com/hydrojs/karma-hydro/blob/master/index.js#L34). So basically for the browserify build I'm assuming we need to build hydro to a temporary location and then supply this location to the config and this will do the trick. Thoughts?

@jkroso
Copy link
Contributor Author

jkroso commented Dec 29, 2013

Yea once I broke the config the browsers stayed open and I was able to look at what code they had loaded. It actually looks pretty nice compared to https://github.com/yields/gravy which works by polling every 1 second for a mochaResults global variable. I was playing with that last night.

With browserify its probably easier to just keep everything under one build so I might create a karma adapter which is just a hydro plugin. Also does karma allow you to use you own html?

@vesln
Copy link
Contributor

vesln commented Dec 30, 2013

re: html I think no, but you could use the html2js preprocessor(https://github.com/karma-runner/karma-html2js-preprocessor) and then modify the DOM manually, shouldn't be too much of a pain. Or you could create a plugin that does it for you (that would be pretty sweet). Why do you need it btw?

@jkroso
Copy link
Contributor Author

jkroso commented Dec 30, 2013

well then I would be adding karma to the test suite rather than the other way around which just makes more sense. Also the mocha html reporter would need to be modified to use karma since it needs a element with ID "mocha" present before it loads. It'll be fine for our use its just something that I feel will eventually be a PITA on other projects where I might consider using karma.

@vesln
Copy link
Contributor

vesln commented Dec 30, 2013

In case you'd be using mocha, there is a mocha adapter for it that the karma guys support, so in this particular case you'd be covered. For other cases, luckily, karma is pretty easy to extend, so it shouldnt be a lot of pain to get it working.

Veselin

On 30.12.2013, at 07:10, Jake Rosoman notifications@github.com wrote:

well then I would be adding karma to the test suite rather than the other way around which just makes more sense. Also the mocha html reporter would need to be modified to use karma since it needs a element with ID "mocha" present before it loads. It'll be fine for our use its just something that I feel will eventually be a PITA on other projects where I might consider using karma.


Reply to this email directly or view it on GitHub.

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.

3 participants