New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement numPassingAsserts
of testCaseResult
#13795
Changes from 14 commits
f442c15
edefeab
4173948
590003b
559c28f
a8e0584
9ecbb59
d4f62c0
a423029
cdfd96f
ba550ce
82e450f
0418a30
94386e1
249388c
8e13c11
e5408ae
2aa739f
886a709
bae470a
607bdb3
309f98d
d683aaf
e920161
7f2f2df
9d0c78a
f3dff25
e5cac79
565fef8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*! | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
class AssertionCountsReporter { | ||
onTestFileResult(test, testResult, aggregatedResult) { | ||
testResult.testResults.forEach((testCaseResult, index) => { | ||
console.log( | ||
`onTestFileResult testCaseResult ${index}: ${testCaseResult.title}, ` + | ||
`status: ${testCaseResult.status}, ` + | ||
`numExpectations: ${testCaseResult.numPassingAsserts}`, | ||
); | ||
}); | ||
} | ||
onTestCaseResult(test, testCaseResult) { | ||
console.log( | ||
`onTestCaseResult: ${testCaseResult.title}, ` + | ||
`status: ${testCaseResult.status}, ` + | ||
`numExpectations: ${testCaseResult.numPassingAsserts}`, | ||
); | ||
} | ||
} | ||
|
||
module.exports = AssertionCountsReporter; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,7 +178,7 @@ export const runAndTransformResultsToJestFormat = async ({ | |
: ancestorTitles.join(' '), | ||
invocations: testResult.invocations, | ||
location: testResult.location, | ||
numPassingAsserts: 0, | ||
numPassingAsserts: testResult.numPassingAsserts, | ||
retryReasons: testResult.retryReasons, | ||
status, | ||
title: testResult.testPath[testResult.testPath.length - 1], | ||
|
@@ -238,6 +238,7 @@ const eventHandler = async (event: Circus.Event) => { | |
break; | ||
} | ||
case 'test_done': { | ||
event.test.numPassingAsserts = jestExpect.getState().numPassingAsserts; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we reset it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
_addSuppressedErrors(event.test); | ||
_addExpectedAssertionErrors(event.test); | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it feasible to hard code jest-circus as the testRunner here? because numPassingAsserts is not implemented in jest-jasmine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use this helper (search the repo for usage examples): https://github.com/facebook/jest/blob/3d7a096680078854b06c213403d063128386ab1f/packages/test-utils/src/ConditionalTest.ts#L18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but it will skip all test of file, it might be better to find a way to skip the specific test.