diff --git a/packages/cli/src/formatters/__tests__/__fixtures__/oas3-schema-errors.json b/packages/cli/src/formatters/__tests__/__fixtures__/oas3-schema-errors.json index 3fcc45ced..b8e6a6dcd 100644 --- a/packages/cli/src/formatters/__tests__/__fixtures__/oas3-schema-errors.json +++ b/packages/cli/src/formatters/__tests__/__fixtures__/oas3-schema-errors.json @@ -51,7 +51,7 @@ }, { "code": "oas3-schema", - "message": "should have required property '$ref'", + "message": "should have required property '$ref' and handle special strings like \", <, > or ]]> well", "path": [ "paths", "/pets", diff --git a/packages/cli/src/formatters/__tests__/junit.test.ts b/packages/cli/src/formatters/__tests__/junit.test.ts index 38b0b865c..cb3e05216 100644 --- a/packages/cli/src/formatters/__tests__/junit.test.ts +++ b/packages/cli/src/formatters/__tests__/junit.test.ts @@ -67,9 +67,10 @@ describe('JUnit formatter', () => { failure: [ { $: { - message: "should have required property '$ref'", + message: + "should have required property '$ref' and handle special strings like \", <, > or ]]> well", }, - _: 'line 36, col 22, should have required property '$ref' (oas3-schema) at path #/paths/~1pets/get/responses/200/headers/header-1', + _: "line 36, col 22, should have required property '$ref' and handle special strings like \", <, > or ]]> well (oas3-schema) at path #/paths/~1pets/get/responses/200/headers/header-1", }, ], }, diff --git a/packages/cli/src/formatters/junit.ts b/packages/cli/src/formatters/junit.ts index b8faa1252..2bd8268e4 100644 --- a/packages/cli/src/formatters/junit.ts +++ b/packages/cli/src/formatters/junit.ts @@ -29,6 +29,13 @@ import { printPath, PrintStyle } from '@stoplight/spectral-runtime'; import { Formatter } from './types'; import { groupBySource, xmlEscape } from './utils'; +/** + * Prepares the given text for inclusion in an XML CDATA section. + */ +function prepareForCdata(text: string): string { + return text.replace(']]>', ']]]]>'); +} + export const junit: Formatter = (results, { failSeverity }) => { let output = ''; @@ -50,8 +57,8 @@ export const junit: Formatter = (results, { failSeverity }) => { output += ``; output += ''; output += ``; output += '\n';