-
Notifications
You must be signed in to change notification settings - Fork 31k
/
Copy pathrenderer.html
130 lines (120 loc) · 4 KB
/
renderer.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<html>
<head>
<meta charset="utf-8">
<title>VSCode Tests</title>
<link href="../../node_modules/mocha/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>
<script src="../../node_modules/mocha/mocha.js"></script>
<script>
// !!! DO NOT CHANGE !!!
// Our unit tests may run in environments without
// display (e.g. from builds) and tests may by
// accident bring up native dialogs or even open
// windows. This we cannot allow as it may crash
// the test run.
// !!! DO NOT CHANGE !!!
window.open = function () { throw new Error('window.open() is not supported in tests!'); };
window.alert = function () { throw new Error('window.alert() is not supported in tests!'); }
window.confirm = function () { throw new Error('window.confirm() is not supported in tests!'); }
// Ignore uncaught cancelled promise errors
window.addEventListener('unhandledrejection', e => {
const name = e && e.reason && e.reason.name;
if (name === 'Canceled') {
e.preventDefault();
e.stopPropagation();
}
});
mocha.setup({
ui: 'tdd',
timeout: 5000
});
</script>
<script src="../../out/vs/loader.js"></script>
<script>
// configure loader
const baseUrl = window.location.href;
require.config({
catchError: true,
baseUrl: new URL('../../src', baseUrl).href,
paths: {
'vs': new URL('../../out/vs', baseUrl).href,
assert: new URL('../assert.js', baseUrl).href,
sinon: new URL('../../node_modules/sinon/pkg/sinon-1.17.7.js', baseUrl).href
}
});
</script>
<script>
function serializeSuite(suite) {
return {
root: suite.root,
suites: suite.suites.map(serializeSuite),
tests: suite.tests.map(serializeRunnable),
title: suite.title,
fullTitle: suite.fullTitle(),
timeout: suite.timeout(),
retries: suite.retries(),
enableTimeouts: suite.enableTimeouts(),
slow: suite.slow(),
bail: suite.bail()
};
}
function serializeRunnable(runnable) {
return {
title: runnable.title,
fullTitle: runnable.fullTitle(),
async: runnable.async,
slow: runnable.slow(),
speed: runnable.speed,
duration: runnable.duration
};
}
function serializeError(err) {
return {
message: err.message,
stack: err.stack,
actual: err.actual,
expected: err.expected,
uncaught: err.uncaught,
showDiff: err.showDiff,
inspect: typeof err.inspect === 'function' ? err.inspect() : ''
};
}
function PlaywrightReporter(runner) {
runner.on('start', () => window.mocha_report('start'));
runner.on('end', () => window.mocha_report('end'));
runner.on('suite', suite => window.mocha_report('suite', serializeSuite(suite)));
runner.on('suite end', suite => window.mocha_report('suite end', serializeSuite(suite)));
runner.on('test', test => window.mocha_report('test', serializeRunnable(test)));
runner.on('test end', test => window.mocha_report('test end', serializeRunnable(test)));
runner.on('hook', hook => window.mocha_report('hook', serializeRunnable(hook)));
runner.on('hook end', hook => window.mocha_report('hook end', serializeRunnable(hook)));
runner.on('pass', test => window.mocha_report('pass', serializeRunnable(test)));
runner.on('fail', (test, err) => window.mocha_report('fail', serializeRunnable(test), serializeError(err)));
runner.on('pending', test => window.mocha_report('pending', serializeRunnable(test)));
};
window.loadAndRun = async function (modules) {
// load
// await Promise.all(modules.map(module => new Promise((resolve, reject) =>{
// require([module], resolve, err => {
// console.log("BAD " + module + JSON.stringify(err, undefined, '\t'));
// // console.log(module);
// resolve({});
// });
// })));
await new Promise((resolve, reject) => {
require(modules, resolve, err => {
console.log(err);
reject(err);
});
});
// run
return new Promise((resolve, reject) => {
mocha.reporter(PlaywrightReporter);
mocha.run(failCount => resolve(failCount === 0));
});
}
</script>
</body>
</html>