Skip to content

Commit d79e4f4

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

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

lib/container.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,13 @@ async function requireHelperFromModule(helperName, config, HelperClass) {
425425
importPath = tempFile
426426
tempJsFile = allTempFiles
427427
fileMapping = mapping
428-
// Store file mapping in container for runtime error fixing
429-
container.tsFileMapping = mapping
428+
// Store file mapping in container for runtime error fixing (merge with existing)
429+
if (!container.tsFileMapping) {
430+
container.tsFileMapping = new Map()
431+
}
432+
for (const [key, value] of mapping.entries()) {
433+
container.tsFileMapping.set(key, value)
434+
}
430435
} catch (tsError) {
431436
throw new Error(`Failed to load TypeScript helper ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
432437
}
@@ -769,8 +774,13 @@ async function loadSupportObject(modulePath, supportObjectName) {
769774
// Store temp files list in a way that cleanup can access them
770775
tempJsFile = allTempFiles
771776
fileMapping = mapping
772-
// Store file mapping in container for runtime error fixing
773-
container.tsFileMapping = mapping
777+
// Store file mapping in container for runtime error fixing (merge with existing)
778+
if (!container.tsFileMapping) {
779+
container.tsFileMapping = new Map()
780+
}
781+
for (const [key, value] of mapping.entries()) {
782+
container.tsFileMapping.set(key, value)
783+
}
774784
} catch (tsError) {
775785
throw new Error(`Failed to load TypeScript file ${importPath}: ${tsError.message}. Make sure 'typescript' package is installed.`)
776786
}

lib/step/base.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,22 @@ class Step {
147147
line() {
148148
const lines = this.stack.split('\n')
149149
if (lines[STACK_LINE]) {
150-
return lines[STACK_LINE].trim()
150+
let line = lines[STACK_LINE].trim()
151151
.replace(global.codecept_dir || '', '.')
152152
.trim()
153+
154+
// Map .temp.mjs back to original .ts files using container's tsFileMapping
155+
const fileMapping = global.container?.tsFileMapping?.()
156+
if (line.includes('.temp.mjs') && fileMapping) {
157+
for (const [tsFile, mjsFile] of fileMapping.entries()) {
158+
if (line.includes(mjsFile)) {
159+
line = line.replace(mjsFile, tsFile)
160+
break
161+
}
162+
}
163+
}
164+
165+
return line
153166
}
154167
return ''
155168
}

0 commit comments

Comments
 (0)