Skip to content

Commit

Permalink
refactor spec reporter according to alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza committed Oct 30, 2021
1 parent 30451e2 commit 703dbd4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
17 changes: 5 additions & 12 deletions spec/helper.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
15 changes: 15 additions & 0 deletions spec/support/CurrentSpecReporter.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 703dbd4

Please sign in to comment.