jon-stevens / jest-hbs-compile

A helper to compile your handlebars templates in your jest tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import the helpers and call compileTemplate, passing in the hbs file, and the model. It will automatically register any partials it finds.

import mainTemplate from 'views/pages/home.hbs';
import model from 'models/home';
import Helpers from './test-helpers';

describe('test block', () => {
	const helpers = new Helpers();

	beforeEach(async () => {
		const html = await helpers.compileTemplate({
			mainTemplate,
			model
		});
		document.body.innerHTML = html;
	});
};

About

A helper to compile your handlebars templates in your jest tests


Languages

Language:JavaScript 100.0%