1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | var test = require('tape');
|
22 |
|
23 | var captureStdio = require('./lib/capture-stdio.js');
|
24 | var ConsoleLogger = require('./lib/console-logger.js');
|
25 |
|
26 | test('can .error("message", new Error())', function (assert) {
|
27 | var logger = ConsoleLogger();
|
28 |
|
29 | assert.ok(captureStdio('error: hello',
|
30 | function logError() {
|
31 | logger.error('hello', new Error('lulz'));
|
32 | }));
|
33 |
|
34 | assert.ok(captureStdio('message=lulz',
|
35 | function logError() {
|
36 | logger.error('hello', new Error('lulz'));
|
37 | }));
|
38 |
|
39 | assert.ok(captureStdio('stack=Error: lulz',
|
40 | function logError() {
|
41 | logger.error('hello', new Error('lulz'));
|
42 | }));
|
43 |
|
44 | assert.end();
|
45 | });
|
46 |
|
47 | test('can error("message", { error: Error() })', function (assert) {
|
48 | var logger = ConsoleLogger();
|
49 |
|
50 | assert.ok(captureStdio('error: some message',
|
51 | function logError() {
|
52 | logger.error('some message', {
|
53 | error: new Error('some error'),
|
54 | other: 'key'
|
55 | });
|
56 | }));
|
57 |
|
58 | assert.ok(captureStdio('message=some error',
|
59 | function logError() {
|
60 | logger.error('some message', {
|
61 | error: new Error('some error'),
|
62 | other: 'key'
|
63 | });
|
64 | }));
|
65 |
|
66 | assert.ok(captureStdio('stack=Error: some error',
|
67 | function logError() {
|
68 | logger.error('some message', {
|
69 | error: new Error('some error'),
|
70 | other: 'key'
|
71 | });
|
72 | }));
|
73 |
|
74 | assert.end();
|
75 | });
|
76 |
|
77 | test('can error(msg, { someKey: Error() })', function (assert) {
|
78 | var logger = ConsoleLogger();
|
79 |
|
80 | assert.ok(captureStdio('error: some message',
|
81 | function logError() {
|
82 | logger.error('some message', {
|
83 | someKey: new Error('some error'),
|
84 | other: 'key'
|
85 | });
|
86 | }));
|
87 |
|
88 | assert.ok(captureStdio('message=some error',
|
89 | function logError() {
|
90 | logger.error('some message', {
|
91 | someKey: new Error('some error'),
|
92 | other: 'key'
|
93 | });
|
94 | }));
|
95 |
|
96 | assert.ok(captureStdio('stack=Error: some error',
|
97 | function logError() {
|
98 | logger.error('some message', {
|
99 | someKey: new Error('some error'),
|
100 | other: 'key'
|
101 | });
|
102 | }));
|
103 |
|
104 | assert.end();
|
105 | });
|