Skip to content

Commit

Permalink
test utils: Include origin of failed browser.* in stack
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jan 6, 2025
1 parent 286c14d commit 03d9168
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/lib/browsers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ export abstract class BrowserInterface<TCurrent = any> {
protected chain<TNext>(
nextCall: (current: TCurrent) => TNext | Promise<TNext>
): BrowserInterface<TNext> & Promise<TNext> {
const promise = Promise.resolve(this.promise).then(nextCall)
const syncError = new Error('next-browser-base-chain-error')
const promise = Promise.resolve(this.promise)
.then(nextCall)
.catch((reason) => {
if (
reason !== null &&
typeof reason === 'object' &&
'stack' in reason
) {
const syncCallStack = syncError.stack.split(syncError.message)[1]
reason.stack += `\n${syncCallStack}`
}
throw reason
})

function get(target: BrowserInterface<TNext>, p: string | symbol): any {
switch (p) {
Expand Down

0 comments on commit 03d9168

Please sign in to comment.