Skip to content

Commit

Permalink
fix: cr
Browse files Browse the repository at this point in the history
  • Loading branch information
Emiyaaaaa committed Aug 1, 2024
1 parent 6b41da6 commit 29faf08
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
13 changes: 5 additions & 8 deletions docs/guide/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,14 @@ Example of a JSON report:
```json
{
"numTotalTestSuites": 4,
"numTodoTestSuites": 1,
"numPassedTestSuites": 2,
"numFailedTestSuites": 1,
"numPassedTestSuites": 1,
"numSkippedTestSuites": 1,
"numPendingTestSuites": 0,
"numPendingTestSuites": 1,
"numTotalTests": 4,
"numTodoTests": 1,
"numFailedTests": 1,
"numPassedTests": 1,
"numSkippedTests": 1,
"numPendingTests": 0,
"numFailedTests": 1,
"numPendingTests": 1,
"numTodoTests": 1,
"startTime": 1697737019307,
"success": false,
"testResults": [
Expand Down
17 changes: 5 additions & 12 deletions packages/vitest/src/node/reporters/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export interface JsonTestResults {
numPendingTests: number
numPendingTestSuites: number
numTodoTests: number
numTodoTestSuites: number
numSkippedTests: number
numSkippedTestSuites: number
numTotalTests: number
numTotalTestSuites: number
startTime: number
Expand Down Expand Up @@ -94,20 +91,19 @@ export class JsonReporter implements Reporter {
const numTotalTestSuites = suites.length
const tests = getTests(files)
const numTotalTests = tests.length

const numFailedTestSuites = suites.filter(s => s.result?.state === 'fail').length
const numPassedTestSuites = suites.filter(s => s.result?.state === 'pass').length
const numSkippedTestSuites = suites.filter(s => s.mode === 'skip' || s.result?.state === 'skip').length
const numTodoTestSuites = suites.filter(s => s.mode === 'todo').length
const numPendingTestSuites = suites.filter(
s => s.result?.state === 'run',
s => s.result?.state === 'run' || s.mode === 'todo',
).length
const numPassedTestSuites = numTotalTestSuites - numFailedTestSuites - numPendingTestSuites

const numFailedTests = tests.filter(
t => t.result?.state === 'fail',
).length
const numPassedTests = tests.filter(t => t.result?.state === 'pass').length
const numSkippedTests = tests.filter(t => t.mode === 'skip' || t.result?.state === 'skip').length
const numPendingTests = tests.filter(
t => t.result?.state === 'run',
t => t.result?.state === 'run' || t.mode === 'skip' || t.result?.state === 'skip',
).length
const numTodoTests = tests.filter(t => t.mode === 'todo').length
const testResults: Array<JsonTestResult> = []
Expand Down Expand Up @@ -181,13 +177,10 @@ export class JsonReporter implements Reporter {
const result: JsonTestResults = {
numTotalTestSuites,
numPassedTestSuites,
numSkippedTestSuites,
numTodoTestSuites,
numFailedTestSuites,
numPendingTestSuites,
numTotalTests,
numPassedTests,
numSkippedTests,
numFailedTests,
numPendingTests,
numTodoTests,
Expand Down
5 changes: 1 addition & 4 deletions test/reporters/tests/__snapshots__/reporters.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ exports[`json reporter (no outputFile entry) 1`] = `
"numPassedTestSuites": 1,
"numPassedTests": 6,
"numPendingTestSuites": 0,
"numPendingTests": 0,
"numSkippedTestSuites": 0,
"numSkippedTests": 1,
"numTodoTestSuites": 0,
"numPendingTests": 1,
"numTodoTests": 1,
"numTotalTestSuites": 2,
"numTotalTests": 9,
Expand Down
3 changes: 0 additions & 3 deletions test/reporters/tests/merge-reports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ test('merge reports', async () => {
"numPassedTests": 3,
"numPendingTestSuites": 0,
"numPendingTests": 0,
"numSkippedTestSuites": 0,
"numSkippedTests": 0,
"numTodoTestSuites": 0,
"numTodoTests": 0,
"numTotalTestSuites": 3,
"numTotalTests": 5,
Expand Down

0 comments on commit 29faf08

Please sign in to comment.