Add dart-json snapshot test

This commit is contained in:
Michal Dorner 2021-01-05 23:43:49 +01:00
parent fef757f6df
commit 9b620ef56a
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
3 changed files with 65 additions and 32 deletions

View file

@ -0,0 +1,26 @@
import * as fs from 'fs'
import * as path from 'path'
import {parseDartJson} from '../src/parsers/dart-json/dart-json-parser'
import {ParseOptions} from '../src/parsers/test-parser'
const xmlFixture = fs.readFileSync(path.join(__dirname, 'fixtures', 'dart-json.json'), {encoding: 'utf8'})
const outputPath = __dirname + '/__outputs__/dart-json.md'
describe('dart-json tests', () => {
it('matches report snapshot', async () => {
const opts: ParseOptions = {
name: 'Dart tests',
annotations: true,
trackedFiles: ['test/main_test.dart', 'test/second_test.dart'],
workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/dart/'
}
const result = await parseDartJson(xmlFixture, opts)
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, result?.output?.summary ?? '')
expect(result.success).toBeFalsy()
expect(result?.output).toMatchSnapshot()
})
})