private getError()

in test-reporter/src/parsers/dart-json/dart-json-parser.ts [158:192]


  private getError(testSuite: TestSuite, test: TestCase): TestCaseError | undefined {
    if (!this.options.parseErrors || !test.error) {
      return undefined
    }

    const {trackedFiles} = this.options
    const stackTrace = test.error?.stackTrace ?? ''
    const print = test.print
      .filter(p => p.messageType === 'print')
      .map(p => p.message)
      .join('\n')
    const details = [print, stackTrace].filter(str => str !== '').join('\n')
    const src = this.exceptionThrowSource(details, trackedFiles)
    const message = this.getErrorMessage(test.error?.error ?? '', print)
    let path
    let line

    if (src !== undefined) {
      path = src.path
      line = src.line
    } else {
      const testStartPath = this.getRelativePath(testSuite.suite.path)
      if (trackedFiles.includes(testStartPath)) {
        path = testStartPath
        line = test.testStart.test.root_line ?? test.testStart.test.line ?? undefined
      }
    }

    return {
      path,
      line,
      message,
      details
    }
  }