mirror of
https://github.com/dorny/test-reporter.git
synced 2026-02-04 04:05:22 -08:00
Add mocha-json test case for empty test results
This commit is contained in:
16
__tests__/fixtures/empty/mocha-json.json
Normal file
16
__tests__/fixtures/empty/mocha-json.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"stats": {
|
||||||
|
"suites": 0,
|
||||||
|
"tests": 0,
|
||||||
|
"passes": 0,
|
||||||
|
"pending": 0,
|
||||||
|
"failures": 0,
|
||||||
|
"start": "2021-03-08T20:01:44.391Z",
|
||||||
|
"end": "2021-03-08T20:01:44.391Z",
|
||||||
|
"duration": 0
|
||||||
|
},
|
||||||
|
"tests": [],
|
||||||
|
"pending": [],
|
||||||
|
"failures": [],
|
||||||
|
"passes": []
|
||||||
|
}
|
||||||
@@ -7,6 +7,23 @@ import {getReport} from '../src/report/get-report'
|
|||||||
import {normalizeFilePath} from '../src/utils/path-utils'
|
import {normalizeFilePath} from '../src/utils/path-utils'
|
||||||
|
|
||||||
describe('mocha-json tests', () => {
|
describe('mocha-json tests', () => {
|
||||||
|
|
||||||
|
it('produces empty test run result when there are no test cases', async () => {
|
||||||
|
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'mocha-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 MochaJsonParser(opts)
|
||||||
|
const result = await parser.parse(filePath, fileContent)
|
||||||
|
expect(result.tests).toBe(0)
|
||||||
|
expect(result.result).toBe('success')
|
||||||
|
})
|
||||||
|
|
||||||
it('report from ./reports/mocha-json test results matches snapshot', async () => {
|
it('report from ./reports/mocha-json test results matches snapshot', async () => {
|
||||||
const fixturePath = path.join(__dirname, 'fixtures', 'mocha-json.json')
|
const fixturePath = path.join(__dirname, 'fixtures', 'mocha-json.json')
|
||||||
const outputPath = path.join(__dirname, '__outputs__', 'mocha-json.md')
|
const outputPath = path.join(__dirname, '__outputs__', 'mocha-json.md')
|
||||||
|
|||||||
Reference in New Issue
Block a user