xolvio / jasmine-unit

A jasmine-based unit-testing framework designed for the Velocity test runner
9 stars 4 forks source link

Jasmine-unit doesn't seem to load #17

Closed queso closed 10 years ago

queso commented 10 years ago

Hey guys,

I just tried adding velocity, jasmine-unit, and velocity-html-reporter to my book example app (https://github.com/Differential/microphone/tree/jasmine-unit) and the stuff isn't working at all.

All I see is the basic reporter and nothing runs, screenshot attached.

jasmine-no-workie

alanning commented 10 years ago

I just tried with your branch and wasn't even able to get the app running, seems to be due to a stubbing issue. Did you see this error?

Exception loading helper: /Users/alanning/tmp/microphone/packages/jasmine-unit/lib/loader-helper.js
[Error: Bootstrap requires jQuery]

Tried including jquery but that didn't work either. How'd you get around this?

queso commented 10 years ago

The app runs, I was able to get to the point you mention above in trying to get things working... It looks like jasmine-unit isn't liking something I am doing, I found the same error in an issue that had to do with stubbing underscore: https://github.com/xolvio/jasmine-unit/issues/6.

alanning commented 10 years ago

I think the problem is that bootstrap (and jquery) are core packages so the aren't linked in the "packages" directory and aren't visible to the package-stubbed.

If you add the bootstrap and jquery js files I think it'll work. May have to play with it a bit.

Looks like we probably need custom stubs for all core packages. PRs welcome in the meteor-package-stubber repo!

On Jun 27, 2014, at 11:36 AM, Josh Owens notifications@github.com wrote:

The app runs, I was able to get to the point you mention above in trying to get things working... It looks like jasmine-unit isn't liking something I am doing, I found the same error in an issue that had to do with stubbing underscore: #6.

— Reply to this email directly or view it on GitHub.

queso commented 10 years ago

We don't use the bootstrap package, we actually just include our own css/js files from it.

Doesn't jquery just come along by default with Meteor?

alanning commented 10 years ago

For unit tests the Meteor context and core packages associated with it are not loaded. So the auto-stubber attempts to create stubs for packages that the app expects to be there by analyzing the "packages" directory.

Since you're loading bootstrap on your own I'd think adding jquery as a custom stub would solve it. I gave it a try by loading the actual jquery lib but got the same error. I'll try some more later today once I get home.

Btw, you can turn on full debugging output by running it like this:

$ DEBUG=1 JASMINE_DEBUG=1 VELOCITY_DEBUG=1 mrt
samhatoum commented 10 years ago

I'm thinking we should add things like underscore/jquery and so forth by default, and allow users to replace with stubs through the settings file.

The reason I say that is because these libraries are more like language extenders and may not be worth the hassle of stubbing. Perhaps we can make it optional per test.

Josh I noticed that you have the old reporter running. A little odd! I'll have a try at your code later and check it also.

queso commented 10 years ago

Yeah,

How do I get the new reporter running?

Josh Owens | 513-678-7081 | @joshowens

On June 27, 2014 at 3:33:05 PM, Sam Hatoum (notifications@github.com) wrote:

I'm thinking we should add things like underscore/jquery and so forth by default, and allow users to replace with stubs through the settings file.

The reason I say that is because these libraries are more like language extenders and may not be worth the hassle of stubbing. Perhaps we can make it optional per test.

Josh I noticed that you have the old reporter running. A little odd! I'll have a try at your code later and check it also.

— Reply to this email directly or view it on GitHub.

rissem commented 10 years ago

Could you try adding it directly to your smart.json file and pointing to the git repo?

"velocity-html-reporter": {
  "git": "https://github.com/rissem/velocity-html-reporter",
  "branch": "master"
}  
alanning commented 10 years ago

Including a stub for jquery gets us past the Bootstrap/jQuery issue. Add this file to tests/jquery-stub.js: https://gist.github.com/alanning/a4262b9ceeade29d91a4

The rest of the client-side packages will also need to be stubbed enough to get it working. Things like Uploader, Minimogoid, etc.

A couple issues are causing the package-stubber to not find client-side packages:

  1. Currently velocity, jasmine-unit, and package-stubber are run in the server-side Meteor context so package-stubber doesn't have visibility to them in the global object.
  2. Even if it did, packages like Uploader and Minimongoid do not actually api.export their objects.

It seems that Meteor has some kind of a special escape-hatch for coffeescript files that allows global objects to truly be global. But this leaves package-stubber with no way to know what to stub.

So in the case of coffeescript packages that don't actually export things, those will require custom exports.

package-stubber has support for custom-packages so we just need to add those into the package-stubber repo as needed. They will automatically be included if that package is found.

An example of this is the iron-router-stub.js file - https://github.com/alanning/meteor-package-stubber/tree/master/package-stubber

samhatoum commented 10 years ago

Is this closable?

queso commented 10 years ago

No, I am still having issues here. I will update my branch and post more info.

queso commented 10 years ago

@rissem I added the line for the html reporter, as asked, and I am getting a new issue. Looks like there is a template missing? I am getting an error about Uncaught Error: Can't find template, helper or data context key: mochaweb which seems to come from the html reporter now.

rissem commented 10 years ago

Yeah, that's a known issue https://github.com/rissem/velocity-html-reporter/issues/6

If you're looking for a quick workaround you could add mocha-web.

queso commented 10 years ago

I had to add mocha-web-velocity to get it working.

queso commented 10 years ago

Ok,

I think I am 99% good to go and the last 1% of the issues lie elsewhere in the velocity-verse.

For the record, I ended up nuking my entire ~/.meteorite source and packages directories and then wiped out all the symlinks in my local app packages folder and reran the mrt command. I am also running against the master branch for velocity, velocity-html-reporter, and for jasmine-unit. The latest master branches have fixes for things like autopublish being removed, no longer needing mocha-web-velocity, etc.