Commit e3ce0cc7 authored by Evgeny Poberezkin's avatar Evgeny Poberezkin Committed by isaacs

Add "passes" opt to include passes in "complete"

Fix #52
parent 337f874b
......@@ -125,6 +125,8 @@ function Parser (options, onComplete) {
this.braceLevel = null
this.parent = options.parent || null
this.failures = []
if (options.passes)
this.passes = []
this.level = options.level || 0
Writable.call(this)
this.buffer = ''
......@@ -453,6 +455,8 @@ function FinalResults (skipAll, self) {
this.skip = skipAll ? self.count : self.skip || 0
this.plan = new FinalPlan(skipAll, self)
this.failures = self.failures
if (self.passes)
this.passes = self.passes
}
function FinalPlan (skipAll, self) {
......@@ -555,6 +559,8 @@ Parser.prototype.emitResult = function () {
this.count++
if (res.ok) {
this.pass++
if (this.passes)
this.passes.push(res)
} else {
this.fail++
if (!res.todo && !res.skip) {
......
......@@ -111,6 +111,8 @@ If `options` is given, it may contain the following flags:
parser to ignore `TAP version 13` lines. Version lines in subtests
cause problems with some parsers, so they are always ignored.
- `passes` boolean which is false by default and will add "passes" property for that contains the result of all passed tests
The `parent`, `level` and `buffered` options are reserved for internal
use.
......
var t = require('tap')
var tapContent = function () {/*
TAP version 13
1..2
ok 1 this is fine
---
message: 1 passed
...
not ok 2
---
message: 2 failed
...
*/}.toString().split('\n').slice(1, -1).join('\n')
var P = require('../')
var etoa = require('events-to-array')
var ignore = [ 'pipe', 'unpipe', 'prefinish', 'finish', 'newListener', 'line', 'version' ]
var p = new P({ passes: true })
var events = etoa(p, ignore)
p.end(tapContent)
t.same(events, [
[
"plan",
{
"start": 1,
"end": 2
}
],
[
"assert",
{
"ok": true,
"id": 1,
"name": "this is fine",
"diag": {
"message": "1 passed"
}
}
],
[
"assert",
{
"ok": false,
"id": 2,
"diag": {
"message": "2 failed"
}
}
],
[
"comment",
"# failed 1 of 2 tests\n"
],
[
"complete",
{
"ok": false,
"count": 2,
"pass": 1,
"fail": 1,
"bailout": false,
"todo": 0,
"skip": 0,
"plan": {
"start": 1,
"end": 2,
"skipAll": false,
"skipReason": "",
"comment": ""
},
"failures": [
{
"ok": false,
"id": 2,
"diag": {
"message": "2 failed"
}
}
],
"passes": [
{
"ok": true,
"id": 1,
"name": "this is fine",
"diag": {
"message": "1 passed"
}
}
]
}
]
], 'saw expected events')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment