xolvio / meteor-rtd-example-project

A template project to use for creating a meteor app with unit and webdriver testing
91 stars 27 forks source link

Problems with _ - underscore - identifier #4

Closed DanielDornhardt closed 11 years ago

DanielDornhardt commented 11 years ago

Hello,

I'm not experienced with unit tests and testing in general and the amount of libs available has my head spinning a bit...

So i was glad to find your example project which seemed to work amazingly well.

But when I tried to add my project to the structure, the following issue occurred:

I am using (underscore.js) in my own code. The first time the phantomjs - Browser encounters a call to from my own code it throws an error:

ReferenceError: Can't find variable: _ .

I'm surprised because neither the mrt command which I use to run meteor (I changed the grunt file) nor the browser in which i open my app seems to have a problem with not finding the identifier "_".

So this might actually be a phantomjs issue more than one connected with your project, and it might have something to do with the recent meteor update (0.6.0)... I think I'll try to get a minimal example running tomorrow if this issue is of interest.

xolvio commented 11 years ago

Hi Daniel. Glad to hear you're find this project useful.

There are two PhantomJS instances that run. One that runs the unit tests, this one is started by karma. And another that runs the acceptance tests, started by grunt. The karma started phantom will require to have any dependancies in the karma.conf.js inside the files array.

Does that solve your problem?

DanielDornhardt commented 11 years ago

Hi, yes, I got it now I think - No bug, just not enough understanding on my part, I guess.

Also I was slightly surprised to receive warnings from phantomjs for all of my code which used Meteor functionality which wasn't stubbed by unit tests yet.

But now I think I got it, I need to stub everything out because Phantomjs runs the JS as it is defined in the karma.conf.js and not really inside of a meteor instance.

Or I could remove the generous

'app/models/**/*.js',
'app/server/**/*.js',
'app/client/**/*.js'

at first and start adding one after another as I write test for them.

Very nice, great work, I'll try wrapping my head around testing (and tests around my code) and I'll definitely let you know how it works. I might write a blog post about it at some point I guess and maybe that could be used as some meat for the documentation as well, because it's a little bit sparse for a newcomer like me.

Thanks and a lot of nicely tested meteor - Projects for you, good sir!

xolvio commented 11 years ago

Great stuff. Have you seen this? http://blog.xolv.io/2013/04/unit-testing-with-meteor.html

If you do end up writing more stub methods, please share as pull requests and we'll collaborate