diff --git a/packages/cli/src/reporters/__tests__/__snapshots__/json-builder.spec.ts.snap b/packages/cli/src/reporters/__tests__/__snapshots__/json-builder.spec.ts.snap index 85cc4508..6a511cb4 100644 --- a/packages/cli/src/reporters/__tests__/__snapshots__/json-builder.spec.ts.snap +++ b/packages/cli/src/reporters/__tests__/__snapshots__/json-builder.spec.ts.snap @@ -1,31 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`JsonBuilder renders JSON markdown output with assets & links: json-with-assets-links 1`] = ` -"{ - "testSessionId": "0c4c64b3-79c5-44a6-ae07-b580ce73f328", - "numChecks": 2, - "runLocation": "eu-west-1", - "checks": [ - { - "result": "Pass", - "name": "my-test.spec.ts", - "checkType": "BROWSER", - "durationMilliseconds": 6522, - "filename": "src/__checks__/folder/browser.check.ts", - "link": "https://app.checklyhq.com/test-sessions/0c4c64b3-79c5-44a6-ae07-b580ce73f328/results/702961fd-7e2c-45f0-97be-1aa9eabd4d82" - }, - { - "result": "Pass", - "name": "Test API check", - "checkType": "API", - "durationMilliseconds": 1234, - "filename": "src/some-other-folder/api.check.ts", - "link": "https://app.checklyhq.com/test-sessions/0c4c64b3-79c5-44a6-ae07-b580ce73f328/results/1c0be612-a5ec-432e-ac1c-837d2f70c010" - } - ] -}" -`; - exports[`JsonBuilder renders basic JSON output with no assets & links: json-basic 1`] = ` "{ "numChecks": 2, @@ -37,7 +11,8 @@ exports[`JsonBuilder renders basic JSON output with no assets & links: json-basi "checkType": "BROWSER", "durationMilliseconds": 6522, "filename": "src/__checks__/folder/browser.check.ts", - "link": null + "link": null, + "runError": null }, { "result": "Pass", @@ -45,7 +20,8 @@ exports[`JsonBuilder renders basic JSON output with no assets & links: json-basi "checkType": "API", "durationMilliseconds": 1234, "filename": "src/some-other-folder/api.check.ts", - "link": null + "link": null, + "runError": null } ] }" diff --git a/packages/cli/src/reporters/__tests__/fixtures/api-check-result.ts b/packages/cli/src/reporters/__tests__/fixtures/api-check-result.ts index 83f28c18..eb98ad30 100644 --- a/packages/cli/src/reporters/__tests__/fixtures/api-check-result.ts +++ b/packages/cli/src/reporters/__tests__/fixtures/api-check-result.ts @@ -135,4 +135,5 @@ export const apiCheckResult = { requestError: null, }, scheduleError: '', + runError: '', } diff --git a/packages/cli/src/reporters/__tests__/fixtures/browser-check-result.ts b/packages/cli/src/reporters/__tests__/fixtures/browser-check-result.ts index a760b8d8..e559374f 100644 --- a/packages/cli/src/reporters/__tests__/fixtures/browser-check-result.ts +++ b/packages/cli/src/reporters/__tests__/fixtures/browser-check-result.ts @@ -159,4 +159,5 @@ export const browserCheckResult = { }, ], scheduleError: '', + runError: '', } diff --git a/packages/cli/src/reporters/__tests__/helpers.ts b/packages/cli/src/reporters/__tests__/helpers.ts index 1f2672c2..cb01d704 100644 --- a/packages/cli/src/reporters/__tests__/helpers.ts +++ b/packages/cli/src/reporters/__tests__/helpers.ts @@ -2,7 +2,11 @@ import { checkFilesMap } from '../abstract-list' import { browserCheckResult } from './fixtures/browser-check-result' import { apiCheckResult } from './fixtures/api-check-result' -export function generateMapAndTestResultIds ({ includeTestResultIds = true }) { +export function generateMapAndTestResultIds ({ includeTestResultIds = true, includeRunErrors = false }) { + if (includeRunErrors) { + browserCheckResult.runError = 'Run error' + apiCheckResult.runError = 'Run error' + } const checkFilesMapFixture: checkFilesMap = new Map([ ['folder/browser.check.ts', new Map([ [browserCheckResult.checkRunId, { diff --git a/packages/cli/src/reporters/__tests__/json-builder.spec.ts b/packages/cli/src/reporters/__tests__/json-builder.spec.ts index 2dc4d2ea..58e58329 100644 --- a/packages/cli/src/reporters/__tests__/json-builder.spec.ts +++ b/packages/cli/src/reporters/__tests__/json-builder.spec.ts @@ -14,6 +14,16 @@ describe('JsonBuilder', () => { }).render() expect(json).toMatchSnapshot('json-basic') }) + test('renders basic JSON output with run errors', () => { + const checkFilesMap = generateMapAndTestResultIds({ includeTestResultIds: false, includeRunErrors: true }) + const json = new JsonBuilder({ + testSessionId: undefined, + numChecks: checkFilesMap.size, + runLocation, + checkFilesMap, + }).render() + expect(json).toMatchSnapshot('json-basic') + }) test('renders JSON markdown output with assets & links', () => { const checkFilesMap = generateMapAndTestResultIds({ includeTestResultIds: true }) const json = new JsonBuilder({ diff --git a/packages/cli/src/reporters/json.ts b/packages/cli/src/reporters/json.ts index b94a104c..5c9dae91 100644 --- a/packages/cli/src/reporters/json.ts +++ b/packages/cli/src/reporters/json.ts @@ -48,6 +48,7 @@ export class JsonBuilder { durationMilliseconds: result.responseTime ?? null, filename: null, link: null, + runError: result.runError || null, } if (this.hasFilenames) {