stack.js (3779B)
1 /** 2 * AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts 3 **/ // Returns the stack trace of an Error, but without the extra boilerplate at the bottom 4 // (e.g. RunCaseSpecific, processTicksAndRejections, etc.), for logging. 5 export function extractImportantStackTrace(e) {let stack = e.stack;if (!stack) { 6 return ''; 7 } 8 const redundantMessage = 'Error: ' + e.message + '\n'; 9 if (stack.startsWith(redundantMessage)) { 10 stack = stack.substring(redundantMessage.length); 11 } 12 13 const lines = stack.split('\n'); 14 for (let i = lines.length - 1; i >= 0; --i) { 15 const line = lines[i]; 16 if (line.indexOf('.spec.') !== -1) { 17 return lines.slice(0, i + 1).join('\n'); 18 } 19 } 20 return stack; 21 } 22 23 // *** Examples *** 24 // 25 // Node fail() 26 // > Error: 27 // > at CaseRecorder.fail (/Users/kainino/src/cts/src/common/framework/logger.ts:99:30) 28 // > at RunCaseSpecific.exports.g.test.t [as fn] (/Users/kainino/src/cts/src/unittests/logger.spec.ts:80:7) 29 // x at RunCaseSpecific.run (/Users/kainino/src/cts/src/common/framework/test_group.ts:121:18) 30 // x at processTicksAndRejections (internal/process/task_queues.js:86:5) 31 // 32 // Node throw 33 // > Error: hello 34 // > at RunCaseSpecific.g.test.t [as fn] (/Users/kainino/src/cts/src/unittests/test_group.spec.ts:51:11) 35 // x at RunCaseSpecific.run (/Users/kainino/src/cts/src/common/framework/test_group.ts:121:18) 36 // x at processTicksAndRejections (internal/process/task_queues.js:86:5) 37 // 38 // Firefox fail() 39 // > fail@http://localhost:8080/out/framework/logger.js:104:30 40 // > expect@http://localhost:8080/out/framework/default_fixture.js:59:16 41 // > @http://localhost:8080/out/unittests/util.spec.js:35:5 42 // x run@http://localhost:8080/out/framework/test_group.js:119:18 43 // 44 // Firefox throw 45 // > @http://localhost:8080/out/unittests/test_group.spec.js:48:11 46 // x run@http://localhost:8080/out/framework/test_group.js:119:18 47 // 48 // Safari fail() 49 // > fail@http://localhost:8080/out/framework/logger.js:104:39 50 // > expect@http://localhost:8080/out/framework/default_fixture.js:59:20 51 // > http://localhost:8080/out/unittests/util.spec.js:35:11 52 // x http://localhost:8080/out/framework/test_group.js:119:20 53 // x asyncFunctionResume@[native code] 54 // x [native code] 55 // x promiseReactionJob@[native code] 56 // 57 // Safari throw 58 // > http://localhost:8080/out/unittests/test_group.spec.js:48:20 59 // x http://localhost:8080/out/framework/test_group.js:119:20 60 // x asyncFunctionResume@[native code] 61 // x [native code] 62 // x promiseReactionJob@[native code] 63 // 64 // Chrome fail() 65 // x Error 66 // x at CaseRecorder.fail (http://localhost:8080/out/framework/logger.js:104:30) 67 // x at DefaultFixture.expect (http://localhost:8080/out/framework/default_fixture.js:59:16) 68 // > at RunCaseSpecific.fn (http://localhost:8080/out/unittests/util.spec.js:35:5) 69 // x at RunCaseSpecific.run (http://localhost:8080/out/framework/test_group.js:119:18) 70 // x at async runCase (http://localhost:8080/out/runtime/standalone.js:37:17) 71 // x at async http://localhost:8080/out/runtime/standalone.js:102:7 72 // 73 // Chrome throw 74 // x Error: hello 75 // > at RunCaseSpecific.fn (http://localhost:8080/out/unittests/test_group.spec.js:48:11) 76 // x at RunCaseSpecific.run (http://localhost:8080/out/framework/test_group.js:119:18)" 77 // x at async Promise.all (index 0) 78 // x at async TestGroupTest.run (http://localhost:8080/out/unittests/test_group_test.js:6:5) 79 // x at async RunCaseSpecific.fn (http://localhost:8080/out/unittests/test_group.spec.js:53:15) 80 // x at async RunCaseSpecific.run (http://localhost:8080/out/framework/test_group.js:119:7) 81 // x at async runCase (http://localhost:8080/out/runtime/standalone.js:37:17) 82 // x at async http://localhost:8080/out/runtime/standalone.js:102:7