summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-04-07 21:51:50 -0500
committerkpdecker <kpdecker@gmail.com>2015-04-07 21:51:50 -0500
commite15af4c84993ef730e1c07168f7cc97bc027f304 (patch)
treeb9092d5d9d250b7c6a17342bd27721b9ec9b4c4b
parentafe730e0594440dd17fdc43271fc4a7db19327f3 (diff)
downloadhandlebars.js-e15af4c84993ef730e1c07168f7cc97bc027f304.zip
handlebars.js-e15af4c84993ef730e1c07168f7cc97bc027f304.tar.gz
handlebars.js-e15af4c84993ef730e1c07168f7cc97bc027f304.tar.bz2
Add require.js error reporting in tests
Adds test coverage for #989
-rw-r--r--spec/amd-runtime.html16
-rw-r--r--spec/amd.html23
2 files changed, 35 insertions, 4 deletions
diff --git a/spec/amd-runtime.html b/spec/amd-runtime.html
index 19bccdb..7cc64f1 100644
--- a/spec/amd-runtime.html
+++ b/spec/amd-runtime.html
@@ -28,11 +28,16 @@
<script src="/spec/env/common.js"></script>
<script>
+ var requireFailure;
+
requirejs.config({
paths: {
'handlebars.runtime': '/dist/handlebars.runtime.amd'
}
});
+ requirejs.onError = function (err) {
+ requireFailure = err;
+ };
</script>
<script>
onload = function(){
@@ -60,6 +65,17 @@
runner.on('fail', logFailure);
+ // Inject any require initilizer failures into the first test so they are properly
+ // reported.
+ if (requireFailure) {
+ runner.on('hook end', function(hook){
+ if (requireFailure) {
+ runner.uncaught(requireFailure);
+ requireFailure = undefined;
+ }
+ });
+ }
+
function logFailure(test, err){
var flattenTitles = function(test){
diff --git a/spec/amd.html b/spec/amd.html
index 864ee83..5de33c1 100644
--- a/spec/amd.html
+++ b/spec/amd.html
@@ -28,12 +28,17 @@
<script src="/spec/env/common.js"></script>
<script>
+ var requireFailure;
+
requirejs.config({
paths: {
handlebars: '/dist/handlebars.amd',
tests: '/tmp/tests'
}
});
+ requirejs.onError = function (err) {
+ requireFailure = err;
+ };
var CompilerContext = {
compile: function(template, options) {
@@ -79,16 +84,26 @@
runner.on('fail', logFailure);
- function logFailure(test, err){
+ // Inject any require initilizer failures into the first test so they are properly
+ // reported.
+ if (requireFailure) {
+ runner.on('hook end', function(hook){
+ if (requireFailure) {
+ runner.uncaught(requireFailure);
+ requireFailure = undefined;
+ }
+ });
+ }
- var flattenTitles = function(test){
+ function logFailure(test, err){
+ function flattenTitles(test){
var titles = [];
while (test.parent.title){
titles.push(test.parent.title);
test = test.parent;
}
return titles.reverse();
- };
+ }
failedTests.push({
name: test.title,
@@ -97,7 +112,7 @@
stack: err.stack,
titles: flattenTitles(test)
});
- };
+ }
});
});
};