[Announcement] New testing package - Meteor Template Isolator

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:

3 Likes

This is slick, thanks!

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

1 Like

Thanks for the package. Is this integrated with velocity?

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

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();
	});
});