Skip to content

Instantly share code, notes, and snippets.

@leegee
Created May 30, 2014 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leegee/cb59872f7bbf35ddfba8 to your computer and use it in GitHub Desktop.
Save leegee/cb59872f7bbf35ddfba8 to your computer and use it in GitHub Desktop.
Client-side Require.js and Mocha.js Runner
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mocha Test Suite Runner</title>
<link rel="stylesheet" media="all" href="vendor/mocha/mocha.css">
<script src='../vendor/require.js'></script>
<script>
/** Needed to run the tests */
var PRE_LIBS = [
'vendor/mocha/mocha.js',
'vendor/chai/chai.js',
'vendor/should/should.js'
];
/** The tests themselves */
var TEST_SPECS = [
'examples/simple.js',
'examples/ajax.js'
];
require(['../require-global-config.js'], function(){
require( PRE_LIBS, function(){
mocha.setup('bdd');
require( TEST_SPECS, function (m){
// mocha.globals(['jQuery', '$']);
// mocha.checkLeaks();
mocha.run();
});
});
});
</script>
</head>
<body>
<header>
<h1>Mocha Tests</h1>
<p>Add tests to this file's <code>TEST_SPECS</code>.</p>
</header>
<section id="mocha" data-comment="Report gets inserted into here"></section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment