-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple junitxml files (#35)
* add `multiple-junitxml-files` to readme * add `withoutHeader` to junit report * move `parseLine` to utils * add full multiple junit support * add tests for multiple junit files * build * 1.0.18 * update readme with screenshot for multiple junit
- Loading branch information
Showing
17 changed files
with
345 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import * as core from '@actions/core' | ||
import { expect, test, describe, jest } from '@jest/globals' | ||
import { getMultipleJunitReport } from '../src/multi-junit-files' | ||
|
||
describe('multi junit report', () => { | ||
test('should not parse when no files', async () => { | ||
// @ts-ignore | ||
const result1 = await getMultipleJunitReport({ multipleJunitFiles: [] }) | ||
// @ts-ignore | ||
const result2 = await getMultipleJunitReport({ multipleJunitFiles: [' '] }) | ||
|
||
expect(result1).toBeNull() | ||
expect(result2).toBeNull() | ||
}) | ||
|
||
test('should throw error on bad format', async () => { | ||
const spy = jest.spyOn(core, 'error') | ||
// @ts-ignore | ||
const result = await getMultipleJunitReport({ | ||
multipleJunitFiles: ['./path/to/file.xml'], | ||
}) | ||
|
||
expect(result).toBeNull() | ||
expect(spy).toHaveBeenCalledTimes(1) | ||
expect(spy).toHaveBeenCalledWith( | ||
`Generating report for multiple junit files. No files are provided` | ||
) | ||
}) | ||
|
||
test('should throw warning when file not exist', async () => { | ||
const spy = jest.spyOn(core, 'warning') | ||
// @ts-ignore | ||
const result = await getMultipleJunitReport({ | ||
multipleJunitFiles: ['title1, ./path/to/junit.xml'], | ||
}) | ||
|
||
expect(result).toBeNull() | ||
expect(spy).toHaveBeenCalledTimes(2) | ||
expect(spy).toHaveBeenCalledWith(`File "./path/to/junit.xml" doesn't exist`) | ||
expect(spy).toHaveBeenCalledWith(`Junit xml was not provided`) | ||
}) | ||
|
||
test('should generate markdown for one file', async () => { | ||
const html = `| Title | Tests | Skipped | Failures | Errors | Time | | ||
| ----- | ----- | ------- | -------- | -------- | ------------------ | | ||
| title1 | 6 | 0 :zzz: | 0 :x: | 0 :fire: | 0.732s :stopwatch: | | ||
` | ||
// @ts-ignore | ||
const result = await getMultipleJunitReport({ | ||
multipleJunitFiles: [`title1, ${__dirname}/../data/coverage_1/junit.xml`], | ||
}) | ||
|
||
expect(result).toBe(html) | ||
}) | ||
|
||
test('should generate markdown for two files', async () => { | ||
const html = `| Title | Tests | Skipped | Failures | Errors | Time | | ||
| ----- | ----- | ------- | -------- | -------- | ------------------ | | ||
| title1 | 6 | 0 :zzz: | 0 :x: | 0 :fire: | 0.732s :stopwatch: | | ||
| title2 | 6 | 0 :zzz: | 0 :x: | 0 :fire: | 0.732s :stopwatch: | | ||
` | ||
// @ts-ignore | ||
const result = await getMultipleJunitReport({ | ||
multipleJunitFiles: [ | ||
`title1, ${__dirname}/../data/coverage_1/junit.xml`, | ||
`title2, ${__dirname}/../data/coverage_1/junit.xml`, | ||
], | ||
}) | ||
|
||
expect(result).toBe(html) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.