From 703dbd45909af041b003ce58169878908137b529 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 30 Oct 2021 19:07:41 +0200 Subject: [PATCH] refactor spec reporter according to alpha --- spec/helper.js | 17 +++++------------ spec/support/CurrentSpecReporter.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 spec/support/CurrentSpecReporter.js diff --git a/spec/helper.js b/spec/helper.js index af59a32182..d9e9b77797 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -1,18 +1,11 @@ 'use strict'; +const CurrentSpecReporter = require('./support/CurrentSpecReporter.js'); +const { SpecReporter } = require('jasmine-spec-reporter'); + // Sets up a Parse API server for testing. jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 5000; - -const SpecReporter = require('jasmine-spec-reporter').SpecReporter; - -jasmine.getEnv().clearReporters(); // remove default reporter logs -jasmine.getEnv().addReporter( - new SpecReporter({ - // add jasmine-spec-reporter - spec: { - displayPending: true, - }, - }) -); +jasmine.getEnv().addReporter(new CurrentSpecReporter()); +jasmine.getEnv().addReporter(new SpecReporter()); global.on_db = (db, callback, elseCallback) => { if (process.env.PARSE_SERVER_TEST_DB == db) { diff --git a/spec/support/CurrentSpecReporter.js b/spec/support/CurrentSpecReporter.js new file mode 100644 index 0000000000..3158e21eae --- /dev/null +++ b/spec/support/CurrentSpecReporter.js @@ -0,0 +1,15 @@ +// Sets a global variable to the current test spec +// ex: global.currentSpec.description + +global.currentSpec = null; + +class CurrentSpecReporter { + specStarted(spec) { + global.currentSpec = spec; + } + specDone() { + global.currentSpec = null; + } +} + +module.exports = CurrentSpecReporter;