From 76f34e90dcb1ba0945436547483ee1bfabbeaac3 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 13 Mar 2021 13:49:30 -0800 Subject: [PATCH] Allow custom object formatters to be added in beforeAll Fixes #1876. --- spec/core/integration/CustomObjectFormatterSpec.js | 2 +- src/core/Env.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/core/integration/CustomObjectFormatterSpec.js b/spec/core/integration/CustomObjectFormatterSpec.js index 2c61d9e0..eec264dc 100644 --- a/spec/core/integration/CustomObjectFormatterSpec.js +++ b/spec/core/integration/CustomObjectFormatterSpec.js @@ -42,7 +42,7 @@ describe('Custom object formatters', function() { }); env.describe('with custom pretty-printer', function() { - env.beforeEach(function() { + env.beforeAll(function() { env.addCustomObjectFormatter(function(obj) { return 'custom(' + obj + ')'; }); diff --git a/src/core/Env.js b/src/core/Env.js index a70413b8..62454373 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -424,6 +424,9 @@ getJasmineRequireObj().Env = function(j$) { resources.customAsyncMatchers = j$.util.clone( runnableResources[parentRunnableId].customAsyncMatchers ); + resources.customObjectFormatters = j$.util.clone( + runnableResources[parentRunnableId].customObjectFormatters + ); resources.defaultStrategyFn = runnableResources[parentRunnableId].defaultStrategyFn; }