Can't load jade template for testing

In my /imports/ui/admin/category folder, there are these files:


As I want to do a test for the template helpers, I do get an error message

Error: Cannot find module './category.jade'

I don’t understand why, as this file exists and the app is working in non-test-mode. What am I doing wrong?


import { Categories } from '../../../api/collections.js';
import './category.jade';

	categories() { 
		return Categories.find( { type: { $exists: false } } ); 

Now I want to do a test for this helper:


import { chai, expect } from 'meteor/practicalmeteor:chai';
import './category.js';

describe("Category helper", function () {
	it("Should return a cursor to the template", function () {
		var categories = Template.categories.__helpers.get('categories');



import './admin/category/category.js';

Which is loaded by…


import '/imports/ui/ui.js';

Just any idea for what I can look? I’m really stucked on that…

A few things that might help:

  • Since you’re testing the UI you might want to move your category.test.js file under a client directory (or wrapping it in a Meteor.isClient check), something like /imports/ui/admin/category/client/category.test.js. This will prevent the test from being run on the server.
  • You’re referencing Template in your test but haven’t brought it in via an import. You’ll likely want to add:
import { Template } from 'meteor/templating';

Thanks for your reply. Didn’t think of the fact to keep this test on client.