feat: add reporter for salesforce apex

This commit is contained in:
Ross Reicks 2024-07-11 11:34:33 -05:00
parent 95058abb17
commit c4f7701aa1
9 changed files with 11991 additions and 5 deletions

View file

@ -0,0 +1,45 @@
import path from 'node:path';
import fs from 'node:fs';
import { ParseOptions } from '../src/test-parser';
import { normalizeFilePath } from '../src/utils/path-utils';
import { ApexJsonParser } from '../src/parsers/apex-json/apex-json-parsers';
import { getReport } from '../src/report/get-report';
describe('apex-json tests', () => {
it('produces empty test run result when there are no test cases', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'apex-json.json')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const opts: ParseOptions = {
parseErrors: true,
trackedFiles: []
}
const parser = new ApexJsonParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result.tests).toBe(0)
expect(result.result).toBe('success')
});
it('matches report snapshot', async () => {
const opts: ParseOptions = {
parseErrors: true,
trackedFiles: []
}
const fixturePath = path.join(__dirname, 'fixtures', 'apex-json.json')
const outputPath = path.join(__dirname, '__outputs__', 'apex-json.md')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const parser = new ApexJsonParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()
const report = getReport([result])
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
});