/
tap_testem.js
43 lines (34 loc) · 1.01 KB
/
tap_testem.js
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
Testem.useCustomAdapter(tapAdapter)
function tapAdapter(socket){
var results = {
failed: 0
, passed: 0
, total: 0
, tests: []
}
socket.emit('tests-start')
Testem.handleConsoleMessage = function(msg){
var m
if (m = msg.match(/^((?:not )?ok) (\d+) (.+)$/)){
var passed = m[1] === 'ok'
var test = {
passed: passed ? 1 : 0,
failed: passed ? 0 : 1,
total: 1,
id: m[2],
name: m[3],
items: []
}
if (passed) results.passed++
else results.failed++
results.total++
socket.emit('test-result', test)
results.tests.push(test)
}else if (msg === '# ok' || msg.match(/^# tests \d+/)){
socket.emit('all-test-results', results)
}
// return false if you want to prevent the console message from
// going to the console
//return false
}
}