-
Notifications
You must be signed in to change notification settings - Fork 341
/
phantom.js
33 lines (31 loc) · 936 Bytes
/
phantom.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
var page = require('webpage').create()
page.open('http://localhost:1234', function() {
function f() {
setTimeout(function () {
var clsName = page.evaluate(function() {
var el = document.getElementById('tests')
return el.className
})
if (!clsName.match(/sink-done/)) f()
else {
var count = 0
var fail = page.evaluate(function () {
var t = ''
var els = document.querySelectorAll('ol#tests .fail .fail')
for (var i = 0; i < els.length; i++) {
t += els[i].textContent + '\n'
}
return {text: t, count: els.length}
})
var pass = !!clsName.match(/sink-pass/)
if (pass) console.log('All tests have passed!')
else {
console.log(fail.count + ' test(s) failed')
console.log(fail.text.trim())
}
phantom.exit(pass ? 0 : 1)
}
}, 10)
}
f()
})