mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Refactoring & cleanup of whole codebase
Improves report summary and annotations
This commit is contained in:
parent
07a0223ee3
commit
60b35d601a
20 changed files with 38784 additions and 33667 deletions
|
|
@ -5,7 +5,7 @@
|
|||
|:---|---:|---:|---:|---:|
|
||||
|[DotnetTests.XUnitTests.CalculatorTests](#r0s0)|3✔️|3❌|1✖️|110ms|
|
||||
### <a id="user-content-r0s0" href="#r0s0">DotnetTests.XUnitTests.CalculatorTests</a> ❌
|
||||
**7** tests were completed in **109.5761ms** with **3** passed, **3** failed and **1** skipped.
|
||||
**7** tests were completed in **110ms** with **3** passed, **3** failed and **1** skipped.
|
||||
|
||||
|Result|Test|Time|
|
||||
|:---:|:---|---:|
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@
|
|||
|packages/pretty-format/src/__tests__/react.test.tsx|55✔️|||325ms|
|
||||
|packages/pretty-format/src/__tests__/ReactElement.test.ts|3✔️|||64ms|
|
||||
### <a id="user-content-r0s75" href="#r0s75">e2e/__tests__/jestChangedFiles.test.ts</a> ❌
|
||||
**10** tests were completed in **9045ms** with **9** passed, **1** failed and **0** skipped.
|
||||
**10** tests were completed in **9.045s** with **9** passed, **1** failed and **0** skipped.
|
||||
|
||||
|Result|Test|Time|
|
||||
|:---:|:---|---:|
|
||||
|
|
@ -419,7 +419,7 @@
|
|||
|✔️|monitors only root paths for hg|281ms|
|
||||
|✔️|handles a bad revision for "changedSince", for hg|949ms|
|
||||
### <a id="user-content-r0s98" href="#r0s98">e2e/__tests__/onlyChanged.test.ts</a> ❌
|
||||
**9** tests were completed in **22281ms** with **8** passed, **1** failed and **0** skipped.
|
||||
**9** tests were completed in **22.281s** with **8** passed, **1** failed and **0** skipped.
|
||||
|
||||
|Result|Test|Time|
|
||||
|:---:|:---|---:|
|
||||
|
|
|
|||
|
|
@ -1,126 +1,106 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`dart-json tests matches report snapshot 1`] = `
|
||||
Object {
|
||||
"annotations": Array [
|
||||
Object {
|
||||
"annotation_level": "failure",
|
||||
"end_line": 13,
|
||||
"message": "Expected: <2>
|
||||
TestRunResult {
|
||||
"path": "fixtures/dart-json.json",
|
||||
"suites": Array [
|
||||
TestSuiteResult {
|
||||
"groups": Array [
|
||||
TestGroupResult {
|
||||
"name": "Test 1",
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"error": undefined,
|
||||
"name": "Test 1 Passing test",
|
||||
"result": "success",
|
||||
"time": 36,
|
||||
},
|
||||
],
|
||||
},
|
||||
TestGroupResult {
|
||||
"name": "Test 1 Test 1.1",
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"error": Object {
|
||||
"line": 13,
|
||||
"message": "Expected: <2>
|
||||
Actual: <1>
|
||||
|
||||
|
||||
package:test_api expect
|
||||
",
|
||||
"path": "test/main_test.dart",
|
||||
"stackTrace": "package:test_api expect
|
||||
test\\\\main_test.dart 13:9 main.<fn>.<fn>.<fn>
|
||||
",
|
||||
"path": "test/main_test.dart",
|
||||
"start_line": 13,
|
||||
"title": "[test\\\\main_test.dart] Test 1 Test 1.1 Failing test",
|
||||
},
|
||||
Object {
|
||||
"annotation_level": "failure",
|
||||
"end_line": 2,
|
||||
"message": "Exception: Some error
|
||||
|
||||
package:darttest/main.dart 2:3 throwError
|
||||
},
|
||||
"name": "Test 1 Test 1.1 Failing test",
|
||||
"result": "failed",
|
||||
"time": 20,
|
||||
},
|
||||
TestCaseResult {
|
||||
"error": Object {
|
||||
"line": 2,
|
||||
"message": "Exception: Some error",
|
||||
"path": "lib/main.dart",
|
||||
"stackTrace": "package:darttest/main.dart 2:3 throwError
|
||||
test\\\\main_test.dart 17:9 main.<fn>.<fn>.<fn>
|
||||
",
|
||||
"path": "lib/main.dart",
|
||||
"start_line": 2,
|
||||
"title": "[test\\\\main_test.dart] Test 1 Test 1.1 Exception in target unit",
|
||||
},
|
||||
Object {
|
||||
"annotation_level": "failure",
|
||||
"end_line": 24,
|
||||
"message": "Exception: Some error
|
||||
|
||||
test\\\\main_test.dart 24:7 main.<fn>.<fn>
|
||||
",
|
||||
"path": "test/main_test.dart",
|
||||
"start_line": 24,
|
||||
"title": "[test\\\\main_test.dart] Test 2 Exception in test",
|
||||
},
|
||||
Object {
|
||||
"annotation_level": "failure",
|
||||
"end_line": 5,
|
||||
"message": "TimeoutException after 0:00:00.000001: Test timed out after 0 seconds.
|
||||
|
||||
dart:isolate _RawReceivePortImpl._handleMessage
|
||||
",
|
||||
"path": "test/second_test.dart",
|
||||
"start_line": 5,
|
||||
"title": "[test\\\\second_test.dart] Timeout test",
|
||||
},
|
||||
],
|
||||
"testRuns": Array [
|
||||
TestRunResult {
|
||||
"path": "fixtures/dart-json.json",
|
||||
"suites": Array [
|
||||
TestSuiteResult {
|
||||
"groups": Array [
|
||||
TestGroupResult {
|
||||
"name": "Test 1",
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"name": "Test 1 Passing test",
|
||||
"result": "success",
|
||||
"time": 36,
|
||||
},
|
||||
],
|
||||
},
|
||||
TestGroupResult {
|
||||
"name": "Test 1 Test 1.1",
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"name": "Test 1 Test 1.1 Failing test",
|
||||
"result": "failed",
|
||||
"time": 20,
|
||||
},
|
||||
TestCaseResult {
|
||||
"name": "Test 1 Test 1.1 Exception in target unit",
|
||||
"result": "failed",
|
||||
"time": 6,
|
||||
},
|
||||
],
|
||||
},
|
||||
TestGroupResult {
|
||||
"name": "Test 2",
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"name": "Test 2 Exception in test",
|
||||
"result": "failed",
|
||||
"time": 12,
|
||||
},
|
||||
],
|
||||
},
|
||||
"name": "Test 1 Test 1.1 Exception in target unit",
|
||||
"result": "failed",
|
||||
"time": 6,
|
||||
},
|
||||
],
|
||||
"name": "test\\\\main_test.dart",
|
||||
"totalTime": undefined,
|
||||
},
|
||||
TestSuiteResult {
|
||||
"groups": Array [
|
||||
TestGroupResult {
|
||||
"name": null,
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"name": "Timeout test",
|
||||
"result": "failed",
|
||||
"time": 37,
|
||||
},
|
||||
TestCaseResult {
|
||||
"name": "Skipped test",
|
||||
"result": "skipped",
|
||||
"time": 14,
|
||||
},
|
||||
],
|
||||
TestGroupResult {
|
||||
"name": "Test 2",
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"error": Object {
|
||||
"line": 24,
|
||||
"message": "Exception: Some error",
|
||||
"path": "test/main_test.dart",
|
||||
"stackTrace": "test\\\\main_test.dart 24:7 main.<fn>.<fn>
|
||||
",
|
||||
},
|
||||
"name": "Test 2 Exception in test",
|
||||
"result": "failed",
|
||||
"time": 12,
|
||||
},
|
||||
],
|
||||
"name": "test\\\\second_test.dart",
|
||||
"totalTime": undefined,
|
||||
},
|
||||
],
|
||||
"totalTime": 3760,
|
||||
"name": "test\\\\main_test.dart",
|
||||
"totalTime": undefined,
|
||||
},
|
||||
TestSuiteResult {
|
||||
"groups": Array [
|
||||
TestGroupResult {
|
||||
"name": null,
|
||||
"tests": Array [
|
||||
TestCaseResult {
|
||||
"error": Object {
|
||||
"line": 5,
|
||||
"message": "TimeoutException after 0:00:00.000001: Test timed out after 0 seconds.",
|
||||
"path": "test/second_test.dart",
|
||||
"stackTrace": "dart:isolate _RawReceivePortImpl._handleMessage
|
||||
",
|
||||
},
|
||||
"name": "Timeout test",
|
||||
"result": "failed",
|
||||
"time": 37,
|
||||
},
|
||||
TestCaseResult {
|
||||
"error": undefined,
|
||||
"name": "Skipped test",
|
||||
"result": "skipped",
|
||||
"time": 14,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"name": "test\\\\second_test.dart",
|
||||
"totalTime": undefined,
|
||||
},
|
||||
],
|
||||
"totalTime": 3760,
|
||||
}
|
||||
`;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,30 +1,29 @@
|
|||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
import {parseDartJson} from '../src/parsers/dart-json/dart-json-parser'
|
||||
import {ParseOptions} from '../src/parsers/parser-types'
|
||||
import {DartJsonParser} from '../src/parsers/dart-json/dart-json-parser'
|
||||
import {ParseOptions} from '../src/test-parser'
|
||||
import {getReport} from '../src/report/get-report'
|
||||
import {normalizeFilePath} from '../src/utils/file-utils'
|
||||
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'dart-json.json')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'dart-json.md')
|
||||
const xmlFixture = {
|
||||
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
|
||||
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
}
|
||||
|
||||
describe('dart-json tests', () => {
|
||||
it('matches report snapshot', async () => {
|
||||
const opts: ParseOptions = {
|
||||
annotations: true,
|
||||
parseErrors: true,
|
||||
trackedFiles: ['lib/main.dart', 'test/main_test.dart', 'test/second_test.dart'],
|
||||
workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/dart/'
|
||||
}
|
||||
|
||||
const result = await parseDartJson([xmlFixture], opts)
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'dart-json.json')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'dart-json.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const parser = new DartJsonParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport(result.testRuns)
|
||||
const report = getReport([result])
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
import {parseDotnetTrx} from '../src/parsers/dotnet-trx/dotnet-trx-parser'
|
||||
import {ParseOptions} from '../src/parsers/parser-types'
|
||||
import {DotnetTrxParser} from '../src/parsers/dotnet-trx/dotnet-trx-parser'
|
||||
import {ParseOptions} from '../src/test-parser'
|
||||
import {getReport} from '../src/report/get-report'
|
||||
import {normalizeFilePath} from '../src/utils/file-utils'
|
||||
|
||||
|
|
@ -10,21 +10,20 @@ describe('dotnet-trx tests', () => {
|
|||
it('matches report snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'dotnet-trx.trx')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'dotnet-trx.md')
|
||||
const xmlFixture = {
|
||||
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
|
||||
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
}
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const opts: ParseOptions = {
|
||||
annotations: true,
|
||||
parseErrors: true,
|
||||
trackedFiles: ['DotnetTests.Unit/Calculator.cs', 'DotnetTests.XUnitTests/CalculatorTests.cs'],
|
||||
workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/dotnet/'
|
||||
}
|
||||
|
||||
const result = await parseDotnetTrx([xmlFixture], opts)
|
||||
const parser = new DotnetTrxParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport(result.testRuns)
|
||||
const report = getReport([result])
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
|
|
@ -32,21 +31,20 @@ describe('dotnet-trx tests', () => {
|
|||
it('report from FluentValidation test results matches snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'FluentValidation.Tests.trx')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'fluent-validation-test-results.md')
|
||||
const xmlFixture = {
|
||||
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
|
||||
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
}
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const opts: ParseOptions = {
|
||||
trackedFiles: [],
|
||||
annotations: true,
|
||||
parseErrors: true,
|
||||
workDir: ''
|
||||
}
|
||||
|
||||
const result = await parseDotnetTrx([xmlFixture], opts)
|
||||
const parser = new DotnetTrxParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport(result.testRuns, {listTests: 'failed'})
|
||||
const report = getReport([result], {listTests: 'failed'})
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
import {parseJestJunit} from '../src/parsers/jest-junit/jest-junit-parser'
|
||||
import {ParseOptions} from '../src/parsers/parser-types'
|
||||
import {JestJunitParser} from '../src/parsers/jest-junit/jest-junit-parser'
|
||||
import {ParseOptions} from '../src/test-parser'
|
||||
import {getReport} from '../src/report/get-report'
|
||||
import {normalizeFilePath} from '../src/utils/file-utils'
|
||||
|
||||
|
|
@ -10,45 +10,43 @@ describe('jest-junit tests', () => {
|
|||
it('report from ./reports/jest test results matches snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'jest-junit.md')
|
||||
const xmlFixture = {
|
||||
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
|
||||
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
}
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const opts: ParseOptions = {
|
||||
annotations: true,
|
||||
parseErrors: true,
|
||||
trackedFiles: ['__tests__/main.test.js', '__tests__/second.test.js', 'lib/main.js'],
|
||||
workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/jest/'
|
||||
}
|
||||
|
||||
const result = await parseJestJunit([xmlFixture], opts)
|
||||
const parser = new JestJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport(result.testRuns)
|
||||
const report = getReport([result])
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
|
||||
it('report from facebook/jest test results matches snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'jest', 'jest-test-results.xml')
|
||||
const filesPath = path.join(__dirname, 'fixtures', 'external', 'jest', 'files.txt')
|
||||
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'jest', 'files.txt')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'jest-test-results.md')
|
||||
const xmlFixture = {
|
||||
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
|
||||
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
}
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const trackedFiles = fs.readFileSync(filesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
||||
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles,
|
||||
annotations: true,
|
||||
workDir: '/home/dorny/dorny/jest/'
|
||||
}
|
||||
|
||||
const result = await parseJestJunit([xmlFixture], opts)
|
||||
const parser = new JestJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport(result.testRuns, {listTests: 'failed'})
|
||||
const report = getReport([result], {listTests: 'failed'})
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue