mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
Add support for mocha-json
This commit is contained in:
parent
f285c4c6d7
commit
9b675bd55f
21 changed files with 1588 additions and 59 deletions
30
src/utils/node-utils.ts
Normal file
30
src/utils/node-utils.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import {normalizeFilePath} from './path-utils'
|
||||
|
||||
export function getExceptionSource(
|
||||
stackTrace: string,
|
||||
trackedFiles: string[],
|
||||
getRelativePath: (str: string) => string
|
||||
): {path: string; line: number} | undefined {
|
||||
const lines = stackTrace.split(/\r?\n/)
|
||||
const re = /\((.*):(\d+):\d+\)$/
|
||||
|
||||
for (const str of lines) {
|
||||
const match = str.match(re)
|
||||
if (match !== null) {
|
||||
const [_, fileStr, lineStr] = match
|
||||
const filePath = normalizeFilePath(fileStr)
|
||||
if (filePath.startsWith('internal/') || filePath.includes('/node_modules/')) {
|
||||
continue
|
||||
}
|
||||
const path = getRelativePath(filePath)
|
||||
if (!path) {
|
||||
continue
|
||||
}
|
||||
if (trackedFiles.includes(path)) {
|
||||
const line = parseInt(lineStr)
|
||||
|
||||
return {path, line}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue