Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
562 changes: 24 additions & 538 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@
"@cucumber/junit-xml-formatter": "0.9.0",
"@cucumber/message-streams": "4.0.1",
"@cucumber/messages": "31.1.0",
"@cucumber/pretty-formatter": "1.0.1",
"@cucumber/pretty-formatter": "2.4.1",
"@cucumber/query": "14.7.0",
"@cucumber/tag-expressions": "8.1.0",
"assertion-error-formatter": "^3.0.0",
"capital-case": "^1.0.4",
Expand Down Expand Up @@ -260,7 +261,6 @@
},
"devDependencies": {
"@cucumber/compatibility-kit": "^26.0.0",
"@cucumber/query": "14.7.0",
"@eslint/compat": "^2.0.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.29.0",
Expand Down
17 changes: 9 additions & 8 deletions src/formatter/builtin/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import { FormatterImplementation } from '../index'
import JsonFormatter from '../json_formatter'
import ProgressFormatter from '../progress_formatter'
import ProgressBarFormatter from '../progress_bar_formatter'
import RerunFormatter from '../rerun_formatter'
import SnippetsFormatter from '../snippets_formatter'
import SummaryFormatter from '../summary_formatter'
import UsageFormatter from '../usage_formatter'
import UsageJsonFormatter from '../usage_json_formatter'
import summaryFormatter from './summary'
import prettyFormatter from './pretty'
import progressFormatter from './progress'
import messageFormatter from './message'
import htmlFormatter from './html'

const builtin = {
// new plugin-based formatters
html: htmlFormatter,
junit: '@cucumber/junit-xml-formatter',
pretty: '@cucumber/pretty-formatter',
message: messageFormatter,
pretty: prettyFormatter,
progress: progressFormatter,
summary: summaryFormatter,
// legacy class-based formatters
json: JsonFormatter,
progress: ProgressFormatter,
'progress-bar': ProgressBarFormatter,
rerun: RerunFormatter,
snippets: SnippetsFormatter,
summary: SummaryFormatter,
usage: UsageFormatter,
'usage-json': UsageJsonFormatter,
} as const satisfies Record<string, FormatterImplementation | string>
Expand All @@ -33,16 +34,16 @@ export const documentation = {
// new plugin-based formatters
html: 'Outputs a HTML report',
junit: 'Produces a JUnit XML report',
message: 'Emits Cucumber messages in newline-delimited JSON',
pretty:
'Writes a rich report of the scenario and example execution as it happens',
message: 'Emits Cucumber messages in newline-delimited JSON',
progress: 'Prints one character per scenario.',
summary: 'Summary output of feature and scenarios',
// legacy class-based formatters
json: JsonFormatter.documentation,
progress: ProgressFormatter.documentation,
'progress-bar': ProgressBarFormatter.documentation,
rerun: RerunFormatter.documentation,
snippets: SnippetsFormatter.documentation,
summary: SummaryFormatter.documentation,
usage: UsageFormatter.documentation,
'usage-json': UsageJsonFormatter.documentation,
} satisfies Record<keyof typeof builtin, string>
15 changes: 15 additions & 0 deletions src/formatter/builtin/pretty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PrettyPrinter } from '@cucumber/pretty-formatter'

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / coverage

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / coverage

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 25.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 25.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 24.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 24.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 22.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 22.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 25.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 25.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/pretty.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'PrettyPrinter'. Did you mean to use 'import PrettyPrinter from "@cucumber/pretty-formatter"' instead?
import { FormatterPlugin } from '../../plugin'

export default {
type: 'formatter',
formatter({ on, stream, write }) {
const printer = new PrettyPrinter(stream, write)
on('message', (envelope) => {
printer.update(envelope)
if (envelope.testRunFinished) {
printer.summarise()
}
})
},
} satisfies FormatterPlugin
15 changes: 15 additions & 0 deletions src/formatter/builtin/progress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ProgressPrinter } from '@cucumber/pretty-formatter'

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / coverage

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / coverage

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 25.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 25.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 24.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 24.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 22.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 22.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 25.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 25.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/progress.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'ProgressPrinter'. Did you mean to use 'import ProgressPrinter from "@cucumber/pretty-formatter"' instead?
import { FormatterPlugin } from '../../plugin'

export default {
type: 'formatter',
formatter({ on, stream, write }) {
const printer = new ProgressPrinter(stream, write)
on('message', (envelope) => {
printer.update(envelope)
if (envelope.testRunFinished) {
printer.summarise()
}
})
},
} satisfies FormatterPlugin
16 changes: 16 additions & 0 deletions src/formatter/builtin/summary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SummaryPrinter } from '@cucumber/pretty-formatter'

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / coverage

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / coverage

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 25.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 25.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 24.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 24.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 22.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 22.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 25.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 25.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.x)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@cucumber/pretty-formatter")' call instead.

Check failure on line 1 in src/formatter/builtin/summary.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.x)

Module '"@cucumber/pretty-formatter"' has no exported member 'SummaryPrinter'. Did you mean to use 'import SummaryPrinter from "@cucumber/pretty-formatter"' instead?
import { Query } from '@cucumber/query'
import { FormatterPlugin } from '../../plugin'

export default {
type: 'formatter',
formatter({ on, stream, write }) {
const query = new Query()
on('message', (envelope) => {
query.update(envelope)
if (envelope.testRunFinished) {
new SummaryPrinter(query, stream, write).printSummary()
}
})
},
} satisfies FormatterPlugin
18 changes: 12 additions & 6 deletions src/runtime/format_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function formatError(
error: Error,
filterStackTraces: boolean
): Pick<TestStepResult, 'message' | 'exception'> {
let processedStackTrace: string
let processedStackTrace: string = error.stack
try {
const parsedStack = errorStackParser.parse(error)
const filteredStack = filterStackTraces
Expand All @@ -17,19 +17,25 @@ export function formatError(
} catch {
// if we weren't able to parse and process, we'll settle for the original
}
const message = format(error, {
const legacyMessage = format(error, {
colorFns: {
errorStack: (stack: string) => {
return processedStackTrace ? `\n${processedStackTrace}` : stack
},
},
})
const type = error.name || 'Error'
const message = typeof error === 'string' ? error : error.message
let stackTrace = `${type}: ${message}`
if (processedStackTrace) {
stackTrace += '\n' + processedStackTrace
}
return {
message,
message: legacyMessage,
exception: {
type: error.name || 'Error',
message: typeof error === 'string' ? error : error.message,
stackTrace: processedStackTrace ?? error.stack,
type,
message,
stackTrace,
},
}
}
43 changes: 23 additions & 20 deletions src/runtime/format_error_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,38 @@ describe('formatError', () => {
}

it('should handle a custom error', () => {
expect(
testFormatError(() => {
assert.ok(false, 'Thing that should have been truthy was falsy!')
})
).to.have.string(' at ')
const result = testFormatError(() => {
assert.ok(false, 'Thing that should have been truthy was falsy!')
})
expect(result).to.have.string(' at ')
expect(result).to.have.string(
'AssertionError: Thing that should have been truthy was falsy!'
)
})

it('should handle a generic error', () => {
expect(
testFormatError(() => {
throw new Error('A generally bad thing happened!')
})
).to.have.string(' at ')
const result = testFormatError(() => {
throw new Error('A generally bad thing happened!')
})
expect(result).to.have.string(' at ')
expect(result).to.have.string(
'Error: A generally bad thing happened!'
)
})

it('should handle an omitted message', () => {
expect(
testFormatError(() => {
throw new Error()
})
).to.have.string(' at ')
const result = testFormatError(() => {
throw new Error()
})
expect(result).to.have.string(' at ')
expect(result).to.have.string('Error: ')
})

it('should handle a thrown string', () => {
expect(
testFormatError(() => {
throw 'Yikes!'
})
).to.be.undefined
const result = testFormatError(() => {
throw 'Yikes!'
})
expect(result).to.eq('Error: Yikes!')
})
})
})
Expand Down
Loading