xolvio / rtd

DEPRECATED: The Test Runner for Meteor
164 stars 37 forks source link

Getting tons of errors when running tests on Templates. #137

Open serviewcare opened 10 years ago

serviewcare commented 10 years ago

So, I'm trying to run rtd on my system for the first time. For some reason I'm getting a load of errors on my Templates:

TypeError: 'undefined' is not an object (evaluating 'Template.cr_notification_area') at /home/jthomas/git-projects/app/client/care_recipient_client/cr_notification_area.js:6

Every single one of them is on line 6 for every template file, and seem to show up at random for all of my templates.

If I evaluate the same templates from JS console, they return HTML, and work just fine in my application.

AdrienLemaire commented 10 years ago

You need to stub your templates. You are running unit tests, you do not want to load meteor for every single test.

Template.stub('cr_notification_area')
PSzu commented 10 years ago

You may consider trying out my oneliner:

grep -r --include *.html "<template name=" app/ | awk -F"<template name=" '{ print $2 }' | cut -d">" -f1 | xargs -I template echo "Template.stub(\""template"\");"

This will generate all template stubs and display them on console:

/scratch/rtd-laika-meteor-boilerplate$ grep -r --include *.html "<template name=" app/ | awk -F"<template name=" '{ print $2 }' | cut -d">" -f1 | xargs -I template echo "Template.stub(\""template"\");"

Template.stub("searchbar"); Template.stub("header"); Template.stub("footer"); Template.stub("notFound"); Template.stub("home"); Template.stub("basicLayout"); Template.stub("slimLayout");

I have an alias in bashrc for that.

samhatoum commented 10 years ago

Interesting, this should probably just happen automagically. I'll look at adding this in. Thanks!

samhatoum commented 10 years ago

A pull request is always welcome of course :)

PSzu commented 10 years ago

Great, thanks!