Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add message and trace #11

Merged
merged 1 commit into from
Aug 6, 2024
Merged
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
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
Loading