diff --git a/src/lib/writers/ResultsWriter.ts b/src/lib/writers/ResultsWriter.ts index 0f6acf073..3d3685977 100644 --- a/src/lib/writers/ResultsWriter.ts +++ b/src/lib/writers/ResultsWriter.ts @@ -35,7 +35,7 @@ export class ResultsFileWriter implements ResultsWriter { } else if (['.html', '.htm'].includes(ext)) { this.format = OutputFormat.HTML; } else if (ext === '.sarif' || file.toLowerCase().endsWith('.sarif.json')) { - throw new Error('TODO: Support SARIF-type output'); + this.format = OutputFormat.SARIF; // Check for `.json` AFTER checking for `.sarif.json`! } else if (ext === '.json') { this.format = OutputFormat.JSON; diff --git a/test/lib/writers/ResultsWriter.test.ts b/test/lib/writers/ResultsWriter.test.ts index b8f2ca632..c85380bf2 100644 --- a/test/lib/writers/ResultsWriter.test.ts +++ b/test/lib/writers/ResultsWriter.test.ts @@ -23,8 +23,8 @@ describe('ResultsWriter implementations', () => { {ext: '.html', expectedOutput: `Results formatted as ${OutputFormat.HTML}`}, {ext: '.htm', expectedOutput: `Results formatted as ${OutputFormat.HTML}`}, {ext: '.json', expectedOutput: `Results formatted as ${OutputFormat.JSON}`}, - //{ext: '.sarif', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, - //{ext: '.sarif.json', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, + {ext: '.sarif', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, + {ext: '.sarif.json', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, {ext: '.xml', expectedOutput: `Results formatted as ${OutputFormat.XML}`} ])('Accepts and outputs valid file format: *$ext', ({ext, expectedOutput}) => { const validFile = `beep${ext}`; @@ -40,20 +40,6 @@ describe('ResultsWriter implementations', () => { }]); }); - /** - * All of these extensions are ones we intend to support long-term, but don't yet. When we add support for one of - * these extensions, we should remove it from the cases array here and uncomment the corresponding line - * in the case array for the valid format tests. - */ - it.each([ - {ext: '.sarif'}, - {ext: '.sarif.json'} - ])('Throws TODO error for not-yet-supported format: *$ext', ({ext}) => { - const notYetSupportedFile = `beep${ext}`; - // Expect the error message to include an indication that the functionality will be implemented eventually. - expect(() => new ResultsFileWriter(notYetSupportedFile)).toThrow('TODO'); - }); - it('Writes file even when results are empty', () => { const expectations = { file: 'beep.csv',