Add mocha-json test case for empty test results

This commit is contained in:
Michal Dorner 2021-03-08 21:04:14 +01:00
parent 3768e4e756
commit 9db99178aa
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
2 changed files with 33 additions and 0 deletions

View 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": []
}

View file

@ -7,6 +7,23 @@ import {getReport} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/path-utils'
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 () => {
const fixturePath = path.join(__dirname, 'fixtures', 'mocha-json.json')
const outputPath = path.join(__dirname, '__outputs__', 'mocha-json.md')