Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80536 views
1
(function () {
2
var Testem = window.Testem
3
var regex = /^((?:not )?ok) (\d+) (.+)$/
4
5
Testem.useCustomAdapter(tapAdapter)
6
7
function tapAdapter(socket){
8
var results = {
9
failed: 0
10
, passed: 0
11
, total: 0
12
, tests: []
13
}
14
15
socket.emit('tests-start')
16
17
Testem.handleConsoleMessage = function(msg){
18
var m = msg.match(regex)
19
if (m) {
20
var passed = m[1] === 'ok'
21
var test = {
22
passed: passed ? 1 : 0,
23
failed: passed ? 0 : 1,
24
total: 1,
25
id: m[2],
26
name: m[3],
27
items: []
28
}
29
30
if (passed) {
31
results.passed++
32
} else {
33
console.error("failure", m)
34
35
results.failed++
36
}
37
38
results.total++
39
40
// console.log("emitted test", test)
41
socket.emit('test-result', test)
42
results.tests.push(test)
43
} else if (msg === '# ok' || msg.match(/^# tests \d+/)){
44
// console.log("emitted all test")
45
socket.emit('all-test-results', results)
46
}
47
48
// return false if you want to prevent the console message from
49
// going to the console
50
// return false
51
}
52
}
53
}())
54
55