Inject a per-runable pretty printer into MatchersUtil
This will allow us to add support for custom object formatters, which will be a per-runable resource like custom matchers, by injecting them into the pretty-printer.
This commit is contained in:
committed by
Steve Gravrock
parent
dec67bd535
commit
1f23f1e4d2
@@ -309,12 +309,25 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
return 'suite' + nextSuiteId++;
|
||||
};
|
||||
|
||||
var makePrettyPrinter = function() {
|
||||
return j$.makePrettyPrinter();
|
||||
};
|
||||
|
||||
var makeMatchersUtil = function() {
|
||||
var customEqualityTesters =
|
||||
runnableResources[currentRunnable().id].customEqualityTesters;
|
||||
return new j$.MatchersUtil({
|
||||
customTesters: customEqualityTesters,
|
||||
pp: makePrettyPrinter()
|
||||
});
|
||||
};
|
||||
|
||||
var expectationFactory = function(actual, spec) {
|
||||
var customEqualityTesters =
|
||||
runnableResources[spec.id].customEqualityTesters;
|
||||
|
||||
return j$.Expectation.factory({
|
||||
util: new j$.MatchersUtil({ customTesters: customEqualityTesters }),
|
||||
util: makeMatchersUtil(),
|
||||
customEqualityTesters: customEqualityTesters,
|
||||
customMatchers: runnableResources[spec.id].customMatchers,
|
||||
actual: actual,
|
||||
@@ -327,11 +340,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
|
||||
var asyncExpectationFactory = function(actual, spec) {
|
||||
var customEqualityTesters =
|
||||
runnableResources[spec.id].customEqualityTesters;
|
||||
|
||||
return j$.Expectation.asyncFactory({
|
||||
util: new j$.MatchersUtil({ customTesters: customEqualityTesters }),
|
||||
util: makeMatchersUtil(),
|
||||
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
||||
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
|
||||
actual: actual,
|
||||
@@ -1143,7 +1153,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
message += error;
|
||||
} else {
|
||||
// pretty print all kind of objects. This includes arrays.
|
||||
message += j$.pp(error);
|
||||
message += makePrettyPrinter()(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user