Ospec: expose messages for passing tests, in addition to failing tests (#2227)
* ospec: all results, failing and passing, include .message and .context Previously only failing tests had .message and .context. * Updated docs * Function was ugly * Ospec verbose passing tests: put changelog update in right place
This commit is contained in:
parent
0fd1bc9cae
commit
b5219920ab
4 changed files with 14 additions and 7 deletions
|
|
@ -287,16 +287,20 @@ else window.o = m()
|
|||
}
|
||||
function define(name, verb, compare) {
|
||||
Assert.prototype[name] = function assert(value) {
|
||||
if (compare(this.value, value)) succeed(this)
|
||||
else fail(this, serialize(this.value) + "\n " + verb + "\n" + serialize(value))
|
||||
var self = this
|
||||
return function(message) {
|
||||
if (!self.pass) self.message = message + "\n\n" + self.message
|
||||
}
|
||||
var message = serialize(self.value) + "\n " + verb + "\n" + serialize(value)
|
||||
if (compare(self.value, value)){
|
||||
succeed(self, message)
|
||||
return function(message) {
|
||||
if (!self.pass) self.message = message + "\n\n" + self.message
|
||||
}
|
||||
}else fail(self, message)
|
||||
}
|
||||
}
|
||||
function succeed(assertion) {
|
||||
function succeed(assertion, message) {
|
||||
results[assertion.i].pass = true
|
||||
results[assertion.i].context = subjects.join(" > ")
|
||||
results[assertion.i].message = message
|
||||
}
|
||||
function fail(assertion, message, error) {
|
||||
results[assertion.i].pass = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue