diff --git a/lib/config/configuration.js b/lib/config/configuration.js index 207327c..428ac0b 100644 --- a/lib/config/configuration.js +++ b/lib/config/configuration.js @@ -35,7 +35,8 @@ export class Configuration { static withConfiguration(aConfiguration) { const defaultConfiguration = require('./default_configuration.json'); - return new this(aConfiguration, defaultConfiguration); + const userConfiguration = require(resolvePathFor(CONFIGURATION_FILE_NAME)); + return new this({ ...userConfiguration, ...aConfiguration }, defaultConfiguration); } constructor(userConfiguration, defaultConfiguration) { this.#userConfigurationOptions = userConfiguration; diff --git a/lib/config/parameters_parser.js b/lib/config/parameters_parser.js index 15b7963..27c4dbf 100644 --- a/lib/config/parameters_parser.js +++ b/lib/config/parameters_parser.js @@ -1,10 +1,10 @@ +import { I18n } from '../i18n/i18n.js'; +import { isString } from '../utils.js'; + /** * I transform a list of console parameters into a valid configuration object. * I can also differentiate between path parameters and configuration parameters. */ -import { I18n } from '../i18n/i18n.js'; -import { isString } from '../utils.js'; - export class ParametersParser { static generateRunConfigurationFromParams(params) { @@ -56,11 +56,11 @@ export class ParametersParser { } static getPathsAndConfigurationParams(allParams) { - const firstConfigParamIndex = allParams.findIndex(param => this.isConfigurationParam(param)); + const firstConfigParamIndex = allParams.findIndex(param => this.isRawConfigurationParam(param)); if (firstConfigParamIndex >= 0) { const paramsAfterFirstConfigurationParam = allParams.slice(firstConfigParamIndex); - const thereIsPathParamAfterConfigParams = paramsAfterFirstConfigurationParam.some(param => !this.isConfigurationParam(param)); + const thereIsPathParamAfterConfigParams = paramsAfterFirstConfigurationParam.some(param => !this.isRawConfigurationParam(param)); if (thereIsPathParamAfterConfigParams) { throw new Error('Run configuration parameters should always be sent at the end of test paths routes'); } @@ -80,6 +80,12 @@ export class ParametersParser { return this.isFailFastParam(param) || this.isRandomizeParam(param) || this.isLanguageParam(param); } + static isRawConfigurationParam(param) { + // pre sanitization + const supportedLanguages = I18n.supportedLanguages(); + return this.isConfigurationParam(param) || supportedLanguages.includes(param); + } + static isFailFastParam(string) { return isString(string) && (string === '-f' || string === '--fail-fast'); }