Skip to content

Commit

Permalink
Add test for line/column info in user-function exception
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Mar 4, 2019
1 parent bcf38f3 commit 057e7b3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/compiler.js
Expand Up @@ -822,6 +822,29 @@
done();
});
});

it('should include error line when exception raised in user function', function(done) {
var tmplStr = [
'{% block content %}',
'<div>{{ foo() }}</div>',
'{% endblock %}',
].join('\n');
var env = new Environment(new Loader('tests/templates'));
var tmpl = new Template(tmplStr, env, 'user-error.njk');

function foo() {
throw new Error('ERROR');
}

tmpl.render({foo: foo}, function(err, res) {
expect(res).to.be(undefined);
expect(err.toString()).to.be([
'Template render error: (user-error.njk) [Line 1, Column 11]',
' Error: ERROR',
].join('\n'));
done();
});
});
}

it('should compile string concatenations with tilde', function(done) {
Expand Down

0 comments on commit 057e7b3

Please sign in to comment.