cli-testing-library
Version:
Simple and complete CLI testing utilities that encourage good testing practices.
58 lines (57 loc) • 1.73 kB
JavaScript
let config = {
asyncUtilTimeout: 1e3,
// Short amount of time to wait for your process to spin up after a `spawn`. AFAIK There's unfortunately not much
// of a better way to do this
renderAwaitTime: 100,
// Internal timer time to wait before attempting error recovery debounce action
errorDebounceTimeout: 100,
unstable_advanceTimersWrapper: (cb) => cb(),
// default value for the `hidden` option in `ByRole` queries
// showOriginalStackTrace flag to show the full error stack traces for async errors
showOriginalStackTrace: false,
// throw errors w/ suggestions for better queries. Opt in so off by default.
throwSuggestions: false,
// called when getBy* queries fail. (message, container) => Error
getInstanceError(message, testInstance) {
let instanceWarning = "";
if (testInstance) {
const stdallArrStr = testInstance.getStdallStr();
instanceWarning = `
${stdallArrStr}`;
} else {
instanceWarning = "";
}
const error = new Error(
[message, instanceWarning].filter(Boolean).join("\n\n")
);
error.name = "TestingLibraryElementError";
return error;
},
_disableExpensiveErrorDiagnostics: false
};
function runWithExpensiveErrorDiagnosticsDisabled(callback) {
try {
config._disableExpensiveErrorDiagnostics = true;
return callback();
} finally {
config._disableExpensiveErrorDiagnostics = false;
}
}
function configure(newConfig) {
if (typeof newConfig === "function") {
newConfig = newConfig(config);
}
config = {
...config,
...newConfig
};
}
function getConfig() {
return config;
}
export {
configure,
getConfig,
runWithExpensiveErrorDiagnosticsDisabled
};
//# sourceMappingURL=config.js.map