File: logger.js

package info (click to toggle)
node-test 0.6.0-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 220 kB
  • sloc: javascript: 865; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 571 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
exports.Logger = function Logger(callback) {
  if (!(this instanceof Logger)) return new Logger(callback)
  this.passes = []
  this.fails = []
  this.errors = []
  this.pass = function (message) {
    this.passes.push(message)
  }
  this.fail = function fail(assertion) {
    this.fails.push(assertion)
  }
  this.error = function error(exception) {
    this.errors.push(exception)
  }
  this.section = function section() {
    return this
  }
  this.report = function report() {
    if (callback)
      callback(this.passes, this.fails, this.errors)
  }
  return this
}