Skip to content

Commit 11400a6

Browse files
committed
fix several 4.x issues
1 parent f3f3ed0 commit 11400a6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/container.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ let container = {
3434
/** @type {Result | null} */
3535
result: null,
3636
sharedKeys: new Set(), // Track keys shared via share() function
37+
tsFileMapping: null, // TypeScript file mapping for error stack fixing
3738
}
3839

3940
/**
@@ -176,6 +177,15 @@ class Container {
176177
return container.translation
177178
}
178179

180+
/**
181+
* Get TypeScript file mapping for error stack fixing
182+
*
183+
* @api
184+
*/
185+
static tsFileMapping() {
186+
return container.tsFileMapping
187+
}
188+
179189
/**
180190
* Get Mocha instance
181191
*
@@ -415,6 +425,8 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
415425
importPath = tempFile
416426
tempJsFile = allTempFiles
417427
fileMapping = mapping
428+
// Store file mapping in container for runtime error fixing
429+
container.tsFileMapping = mapping
418430
} catch (tsError) {
419431
throw new Error(`Failed to load TypeScript helper ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
420432
}
@@ -757,6 +769,8 @@ async function loadSupportObject(modulePath, supportObjectName) {
757769
// Store temp files list in a way that cleanup can access them
758770
tempJsFile = allTempFiles
759771
fileMapping = mapping
772+
// Store file mapping in container for runtime error fixing
773+
container.tsFileMapping = mapping
760774
} catch (tsError) {
761775
throw new Error(`Failed to load TypeScript file ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
762776
}

lib/step/record.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import output from '../output.js'
55
import store from '../store.js'
66
import { TIMEOUT_ORDER } from '../timeout.js'
77
import retryStep from './retry.js'
8+
import { fixErrorStack } from '../utils/typescript.js'
9+
import Container from '../container.js'
810
function recordStep(step, args) {
911
step.status = 'queued'
1012

@@ -60,6 +62,13 @@ function recordStep(step, args) {
6062
recorder.catch(err => {
6163
step.status = 'failed'
6264
step.endTime = +Date.now()
65+
66+
// Fix error stack to point to original .ts files
67+
const fileMapping = Container.tsFileMapping()
68+
if (fileMapping) {
69+
fixErrorStack(err, fileMapping)
70+
}
71+
6372
event.emit(event.step.failed, step, err)
6473
event.emit(event.step.finished, step)
6574
throw err

0 commit comments

Comments
 (0)