From 86f2a242f0b8ff9e11ed564738fa956b47f8694c Mon Sep 17 00:00:00 2001 From: Dallas Johnson Date: Tue, 8 Oct 2019 01:24:25 +0100 Subject: [PATCH] Adds an extra config option to allow customising the mocha test reporter style to suit specific dev environments. --- src/cli/utils.ts | 1 + src/configManager.ts | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cli/utils.ts b/src/cli/utils.ts index eef91f9..5afb38c 100644 --- a/src/cli/utils.ts +++ b/src/cli/utils.ts @@ -275,6 +275,7 @@ export const runTests = async () => { // pretty reasonable in our case and it's possible a successful test would take 10 seconds. mocha.slow(TEST_EXPECTED_DURATION); mocha.timeout(TEST_TIMEOUT_DURATION); + mocha.reporter(ConfigManager.testReporter); // Run the tests. await new Promise((resolve, reject) => diff --git a/src/configManager.ts b/src/configManager.ts index ef35c34..beb0079 100644 --- a/src/configManager.ts +++ b/src/configManager.ts @@ -1,6 +1,7 @@ import axios from 'axios'; import * as path from 'path'; import * as mkdirpCallback from 'mkdirp'; +import * as Mocha from 'mocha'; import { readFile as readFileCallback, writeFile as writeFileCallback, @@ -29,6 +30,8 @@ export interface LamingtonConfig { exclude?: Array; debugTransactions?: boolean; debug: LamingtonDebugLevel; + reporter?: string; + reporterOptions?: any; } /** Level of debug output */ @@ -67,7 +70,6 @@ export class ConfigManager { * @author Mitch Pierias */ public static async initWithDefaults() { - DEFAULT_CONFIG.cdt = await ConfigManager.getAssetURL('EOSIO', 'eosio.cdt', 'amd64.deb'); DEFAULT_CONFIG.eos = await ConfigManager.getAssetURL('EOSIO', 'eos', 'ubuntu-18.04'); @@ -161,8 +163,8 @@ export class ConfigManager { // Read existing configuration and store ConfigManager.config = { ...DEFAULT_CONFIG, - ...JSON.parse(await readFile(atPath, ENCODING)) - } + ...JSON.parse(await readFile(atPath, ENCODING)), + }; } /** @@ -215,4 +217,12 @@ export class ConfigManager { static get exclude() { return (ConfigManager.config && ConfigManager.config.exclude) || DEFAULT_CONFIG.exclude; } + + /** + * Returns the array of excluded strings or patterns + * @author Dallas Johnson + */ + static get testReporter() { + return (ConfigManager.config && ConfigManager.config.reporter) || Mocha.reporters.Min; + } }