Skip to content

Commit

Permalink
Merge pull request #11 from ctrf-io/feat/message-trace
Browse files Browse the repository at this point in the history
feat: add message and trace
completes #11
  • Loading branch information
Ma11hewThomas authored Aug 6, 2024
2 parents ef837d0 + 532569a commit 1c0e532
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ The test object in the report includes the following [CTRF properties](https://c
| `name` | String | Required | The name of the test. |
| `status` | String | Required | The outcome of the test. One of: `passed`, `failed`, `skipped`, `pending`, `other`. |
| `duration` | Number | Required | The time taken for the test execution, in milliseconds. |
| `message` | String | Optional | The failure message if the test failed. |
| `trace` | String | Optional | The stack trace captured if the test failed. |

## Support Us

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "newman-reporter-ctrf-json",
"version": "0.0.4",
"description": "",
"version": "0.0.5",
"description": "Create a common JSON test report for Postman Newman tests",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
Expand All @@ -15,8 +15,9 @@
"dist/",
"README.md"
],
"author": "",
"license": "ISC",
"repository": "github:ctrf-io/newman-reporter-ctrf-json",
"author": "Matthew Thomas",
"license": "MIT",
"devDependencies": {
"@types/newman": "^5.3.5",
"@types/node": "^20.8.10",
Expand Down
5 changes: 4 additions & 1 deletion src/generate-report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from 'fs'
import { type EventEmitter } from 'events'
import {
type CtrfTest,
type CtrfEnvironment,
type CtrfReport,
type CtrfTestState,
Expand Down Expand Up @@ -127,7 +128,7 @@ class GenerateCtrfReport {
execution.assertions.forEach((assertion) => {
this.ctrfReport.results.summary.tests += 1

const testResult = {
const testResult: CtrfTest = {
name: assertion.assertion,
status:
assertion.error != null
Expand All @@ -137,6 +138,8 @@ class GenerateCtrfReport {
}

if (assertion.error != null) {
testResult.message = assertion.error.message
testResult.trace = assertion.error.stack
this.ctrfReport.results.summary.failed += 1
} else {
this.ctrfReport.results.summary.passed += 1
Expand Down

0 comments on commit 1c0e532

Please sign in to comment.