-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
44 lines (40 loc) · 1.5 KB
/
test.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
var PassThrough = require('stream').PassThrough;
var FailureReporter = require('./index');
var assert = require('chai').assert;
describe('test failure reporter', function() {
it('writes out result without passes', function() {
var stream = new PassThrough();
var reporter = new FailureReporter(stream);
reporter.report('phantomjs', {
name: 'it does stuff',
passed: true,
logs: []
});
reporter.report('phantomjs', {
name: 'it fails',
passed: false,
error: new Error('at host:port/path:line: it crapped out'),
logs: ["I am a log", "Useful information"]
});
reporter.finish();
var output = stream.read().toString();
// one line per failure plus three for summary
assert.equal(output.split('\n').length, 4);
assert.match(output, /1\/2 failed/);
});
it('writes out errors', function() {
var stream = new PassThrough();
var reporter = new FailureReporter(stream);
reporter.report('phantomjs', {
name: 'it fails',
passed: false,
error: new Error('at host:port/path:line: it crapped out'),
logs: ["I am a log", "Useful information"]
});
reporter.finish();
var output = stream.read().toString();
// one line per failure plus three for summary
assert.equal(output.split('\n').length, 4);
assert.match(output, /it crapped out/);
});
});