Skip to content

Commit

Permalink
fix: passes, failures, skipped counting
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Feb 5, 2025
1 parent ee4ec7e commit c9d00d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
11 changes: 4 additions & 7 deletions packages/cmd/src/services/convert/postman/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ export function createSuiteJson(

let accTestTime = 0;

const passes = testcases.filter(
(tc) => (tc.failure ?? []).length === 0
).length;
const failures = testcases.filter(
(tc) => (tc.failure ?? []).length > 0
).length;
const failures = testcases.filter((tc) => 'failure' in tc).length;
const skipped = testcases.filter((tc) => 'skipped' in tc).length;
const passes = testcases.length - failures - skipped;

const suiteJson: InstanceReport = {
groupId,
Expand All @@ -69,7 +66,7 @@ export function createSuiteJson(
tests: suite.tests ? parseInt(suite.tests) : 0,
passes,
pending: 0,
skipped: 0,
skipped,
failures,
flaky: 0,
wallClockStartedAt: startTime,
Expand Down
7 changes: 5 additions & 2 deletions packages/cmd/src/services/convert/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export function getTestCase(
const failures = ensureArray<string | Failure>(testCase.failure);
const hasFailure = failures.length > 0;
const suiteTimestamp = suite?.timestamp ?? '';
const skipped = 'skipped' in testCase;

const state = skipped ? 'skipped' : hasFailure ? 'failed' : 'passed';

return {
_t: getTimestampValue(suiteTimestamp),
Expand All @@ -26,9 +29,9 @@ export function getTestCase(
suiteName
),
title: getTestTitle(testCase.name, suiteName),
state: hasFailure ? 'failed' : 'passed',
state: state,
isFlaky: getTestFlakiness(),
expectedStatus: hasFailure ? 'skipped' : 'passed',
expectedStatus: state,
timeout: getTimeout(),
location: getTestCaseLocation(suite?.file ?? ''),
retries: getTestRetries(failures),
Expand Down
4 changes: 2 additions & 2 deletions packages/cmd/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// possible currents test case statuses from reported results
export type TestCaseStatus = 'passed' | 'failed' | 'pending';
export type TestCaseStatus = 'passed' | 'failed' | 'pending' | 'skipped';

// currents values suitable for jest status
export type TestRunnerStatus = 'passed' | 'failed' | 'skipped';

// currents values suitable for jest expected status
export type ExpectedStatus = 'passed' | 'skipped';
export type ExpectedStatus = 'passed' | 'skipped' | 'failed';

// jest test case statuses available in results
export type JestTestCaseStatus = 'pending' | 'todo' | 'failed' | 'passed';
Expand Down

0 comments on commit c9d00d8

Please sign in to comment.