mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Add mocha-json test case for empty test results
This commit is contained in:
parent
3768e4e756
commit
9db99178aa
2 changed files with 33 additions and 0 deletions
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')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue