[Announcement] New testing package - Meteor Template Isolator


#1

This package allows you to seamlessly isolate event code from templates so you can test events. It exposes the events at:

Template.myTemplate.__interceptedEvents

See here for an example:


#2

This is slick, thanks!


#3

Thanks @tjames501

I just added some syntactic sugar to make calling the template easier, you can now use:

Template.myTemplate.fireEvent('click button')

And you can optionally provide a context, an event and a templateInstance!

See an example app and test here


#4

Thanks for the package. Is this integrated with velocity?


#5

It’s an optional package. You just add it with meteor add xolvio:template-isolator


#6

Could you please give an example how to use the template-parameter of an event?

'click li': function(event, template) {
	const 	$this = $(event.currentTarget),
			type  = $this.attr('data-type');

	template.dict.set('section', type);
}

I need to test for a ReactiveDict variable…

describe('Events', function() {
	it('set selected type', function (done) {
		const expectedValue = 'anything';
		Template.redactor.fireEvent('click li'); 
	  	expect(reactiveDict).to.be.equal(expectedValue);
	  	done();
	});
});