Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
) {
const errorMessage =
` Unexpected value for ${valueName} ` +
`at index ${valueIndex} of reporter at index ${reporterIndex}\n` +
' Expected:\n' +
` ${chalk.bold.red(expectedType)}\n` +
' Got:\n' +
` ${chalk.bold.green(getType(value))}\n` +
` Reporter configuration:\n` +
` ${chalk.bold.green(
JSON.stringify(arrayReporter, null, 2)
.split('\n')
.join('\n '),
)}`;
return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE);
}
function errorOut(message) {
const comment = `${chalk.bold.red(
'Configuration documentation'
)}: ${chalk.underline(
'https://github.com/jest-community/jest-watch-toggle-config#readme'
)}
`.trim()
throw new ValidationError('Watch Toggle Config Error', message, comment)
}
export function createReporterError(
reporterIndex: number,
reporterValue: Array | string,
) {
const errorMessage =
` Reporter at index ${reporterIndex} must be of type:\n` +
` ${chalk.bold.green(validReporterTypes.join(' or '))}\n` +
` but instead received:\n` +
` ${chalk.bold.red(getType(reporterValue))}`;
return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE);
}
const createValidationError = (message: string) =>
new ValidationError(`${BULLET}Validation Error`, message, DOCUMENTATION_NOTE);
const createConfigError = (message: string) =>
new ValidationError(ERROR, message, DOCUMENTATION_NOTE);