mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-28 01:56:00 -05:00
test: strip regenerator-runtime from stack traces
This commit is contained in:
parent
f7dd708619
commit
8ce6a75939
1 changed files with 18 additions and 1 deletions
|
@ -19,6 +19,23 @@ const {By, Key, until} = webdriver;
|
|||
// The Jasmine default timeout is 30 seconds so make sure this is lower.
|
||||
const DEFAULT_TIMEOUT_MILLISECONDS = 20 * 1000;
|
||||
|
||||
// This removes confusing `regenerator-runtime` noise from stack traces.
|
||||
// This is V8-specific code. Please don't use it in a browser or any production code.
|
||||
const oldPrepareStackTrace = Error.prepareStackTrace;
|
||||
Error.prepareStackTrace = function (error, stack) {
|
||||
stack = stack.filter(callsite => {
|
||||
const filename = callsite.getFileName();
|
||||
return filename && !filename.includes('regenerator-runtime');
|
||||
});
|
||||
if (oldPrepareStackTrace) {
|
||||
return oldPrepareStackTrace(error, stack);
|
||||
}
|
||||
return [
|
||||
`${error.constructor.name}: ${error.message}`,
|
||||
...stack.map(callsite => ` at ${callsite.toString()}`)
|
||||
].join('\n');
|
||||
};
|
||||
|
||||
/**
|
||||
* An error that can be chained to another error.
|
||||
* @extends Error
|
||||
|
@ -88,7 +105,7 @@ class SeleniumHelperError extends ChainableError {
|
|||
constructor (message, kvList = []) {
|
||||
const baseMessage = [
|
||||
message,
|
||||
...kvList.map(kv => `\t${Object.keys(kv)[0]}: ${Object.values(kv)[0]}`)
|
||||
...kvList.map(kv => ` ${Object.keys(kv)[0]}: ${Object.values(kv)[0]}`)
|
||||
].join('\n');
|
||||
super(baseMessage);
|
||||
Object.setPrototypeOf(this, SeleniumHelperError.prototype); // see https://stackoverflow.com/a/41102306
|
||||
|
|
Loading…
Reference in a new issue