Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
handlebars.js/spec/index.html
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
98 lines (90 sloc)
2.8 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Mocha</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" /> | |
<style> | |
.headless .suite > h1, | |
.headless .test.pass { | |
display: none; | |
} | |
</style> | |
<script> | |
// Show only errors in "headless", non-interactive mode. | |
if (/headless=true/.test(location.href)) { | |
document.documentElement.className = 'headless'; | |
} | |
</script> | |
<script src="/node_modules/sinon/pkg/sinon.js"></script> | |
<script src="/node_modules/chai/chai.js"></script> | |
<script src="/node_modules/dirty-chai/lib/dirty-chai.js"></script> | |
<script src="/node_modules/mocha/mocha.js"></script> | |
<script> | |
window.expect = chai.expect; | |
mocha.setup('bdd'); | |
</script> | |
<script src="/dist/handlebars.js"></script> | |
<script src="/spec/env/common.js"></script> | |
<script> | |
var CompilerContext = { | |
compile: function(template, options) { | |
var templateSpec = handlebarsEnv.precompile(template, options); | |
return handlebarsEnv.template(safeEval(templateSpec)); | |
}, | |
compileWithPartial: function(template, options) { | |
return handlebarsEnv.compile(template, options); | |
} | |
}; | |
function safeEval(templateSpec) { | |
try { | |
var ret; | |
eval('ret = ' + templateSpec); | |
return ret; | |
} catch (err) { | |
console.error(templateSpec); | |
throw err; | |
} | |
} | |
</script> | |
<script src="/tmp/tests.js"></script> | |
<script> | |
onload = function(){ | |
mocha.globals(['mochaResults']) | |
// The test harness leaks under FF. We should have decent global leak coverage from other tests | |
if (!navigator.userAgent.match(/Firefox\/([\d.]+)/)) { | |
mocha.checkLeaks(); | |
} | |
var runner = mocha.run(); | |
// Reporting to test-runner | |
var failedTests = []; | |
runner.on('end', function(){ | |
window.mochaResults = runner.stats; | |
window.mochaResults.reports = failedTests; | |
}); | |
runner.on('fail', logFailure); | |
function logFailure(test, err){ | |
var flattenTitles = function(test){ | |
var titles = []; | |
while (test.parent.title){ | |
titles.push(test.parent.title); | |
test = test.parent; | |
} | |
return titles.reverse(); | |
}; | |
failedTests.push({ | |
name: test.title, | |
result: false, | |
message: err.message, | |
stack: err.stack, | |
titles: flattenTitles(test) | |
}); | |
}; | |
}; | |
</script> | |
</head> | |
<body> | |
<div id="mocha"></div> | |
</body> | |
</html> |