testem 3.13.0 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -187,6 +187,14 @@ For improved ergonomics, TAP reporter does not actually strictly adhere to the S
187
187
  }
188
188
  ```
189
189
 
190
+ By default, the TAP reporter outputs the result of `JSON.stringify()` for any log content that is not a `String`. You can override this behavior by specifying a function for `tap_log_processor`.
191
+
192
+ ```js
193
+ {
194
+ "tap_log_processor": function(log) { return log.toString(); }
195
+ }
196
+ ```
197
+
190
198
  ## Other Test Reporters
191
199
 
192
200
  Testem has other test reporters besides TAP: `dot`, `xunit` and `teamcity`. You can use the `-R` to specify them
@@ -18,6 +18,7 @@ module.exports = class TapReporter {
18
18
  this.results = [];
19
19
  this.errors = [];
20
20
  this.logs = [];
21
+ this.logProcessor = config.get('tap_log_processor');
21
22
  }
22
23
 
23
24
  report(prefix, data) {
@@ -56,7 +57,7 @@ module.exports = class TapReporter {
56
57
  */
57
58
  display(prefix, result) {
58
59
  if (this.willDisplay(result)) {
59
- this.out.write(displayutils.resultString(this.id++, prefix, result, this.quietLogs, this.strictSpecCompliance));
60
+ this.out.write(displayutils.resultString(this.id++, prefix, result, this.quietLogs, this.strictSpecCompliance, this.logProcessor));
60
61
  }
61
62
  }
62
63
 
@@ -57,7 +57,7 @@ function resultDisplay(id, prefix, result, strictSpecCompliance) {
57
57
  return output;
58
58
  }
59
59
 
60
- function yamlDisplay(err, logs) {
60
+ function yamlDisplay(err, logs, logProcessor) {
61
61
  let testLogs;
62
62
  let failed = Object.keys(err || {})
63
63
  .filter(key => key !== 'passed')
@@ -68,7 +68,11 @@ function yamlDisplay(err, logs) {
68
68
  let logLine;
69
69
  if (strutils.isString(log)) {
70
70
  logLine = log;
71
- } else {
71
+ }
72
+ else if (logProcessor) {
73
+ logLine = logProcessor(log);
74
+ }
75
+ else {
72
76
  logLine = JSON.stringify(log);
73
77
  }
74
78
  return strutils.indent(logLine);
@@ -84,10 +88,10 @@ function yamlDisplay(err, logs) {
84
88
  ].join('\n'));
85
89
  }
86
90
 
87
- function resultString(id, prefix, result, quietLogs, strictSpecCompliance) {
91
+ function resultString(id, prefix, result, quietLogs, strictSpecCompliance, logProcessor) {
88
92
  let string = resultDisplay(id, prefix, result, strictSpecCompliance) + '\n';
89
93
  if (result.error || (!quietLogs && result.logs && result.logs.length)) {
90
- string += yamlDisplay(result.error, result.logs) + '\n';
94
+ string += yamlDisplay(result.error, result.logs, logProcessor) + '\n';
91
95
  }
92
96
  return string;
93
97
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "unittest",
8
8
  "browser"
9
9
  ],
10
- "version": "3.13.0",
10
+ "version": "3.14.0",
11
11
  "author": "Toby Ho <airportyh@gmail.com>",
12
12
  "repository": {
13
13
  "type": "git",
@@ -80,7 +80,6 @@
80
80
  "eslint-plugin-chai-expect": "^3.0.0",
81
81
  "eslint-plugin-mocha": "^10.0.3",
82
82
  "mocha": "^9.2.0",
83
- "phantomjs": "^2.1.7",
84
83
  "request": "^2.51.0",
85
84
  "saucie": "^3.3.3",
86
85
  "shelljs": "^0.8.2",