-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
84 lines (73 loc) · 1.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Test Mocha</title>
<link href='../node_modules/mocha/mocha.css' rel='stylesheet' />
<script src='../node_modules/mocha/mocha.js'></script>
<script src='../node_modules/requirejs/require.js'></script>
<script>
requirejs.config({
baseUrl:'.',
paths:{
'chai':'./node_modules/chai/chai'
}
});
mocha.setup({
ui: 'bdd',
ignoreLeaks: true
});
</script>
<style>
.note{
font-size: 12px;
width: 400px;
}
</style>
</head>
<body>
<h2>Test Mocha</h2>
<p class='note'>
This is a very rough example for how to get Mocha running in the browser with require.js
It is not extensive; it was mainly used for fact finding for getting mocha, require.js, and Node.js
to work together.
</p>
<div id="mocha"></div>
<script>
// chai needed to be loaded throuh requirejs, or things got confused.
require(['chai'], function(chai){
window.chai = chai;
// This was an attempt to override dependencies using their relative-path identifiers.
// This works in the browser, but in Node it's impossible to get a handle on `define`.
// Left here for posterity.
window.stubs = {};
var __define = define;
window.define = function(deps, cb){
if(Array.isArray(deps)){
var i, dep;
for(i=0;i<deps.length;i++){
if(stubs[deps[i]]){
console.log('stubbit!');
dep = deps[i];
break;
}
}
if(dep){
__define(deps, function(){
arguments[i] = stubs[deps[i]];
console.log('stubbify');
return cb.apply(null, arguments);
});
return;
}
}
__define(deps, cb);
};
var mochaRun = mocha.run;
// load files and pass them to the mocha runner.
require([
'lib/tests/Main_spec_browser'
], mochaRun);
})
</script>
</body>
</html>