-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Merged
Merged
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f442c15
chore: numPassingAsserts type
ymqy edefeab
chore: numPassingAsserts default value
ymqy 4173948
chore: increment numPassingAsserts
ymqy 590003b
chore: numPassingAsserts type
ymqy 559c28f
chore: add numPassingAsserts to testResult
ymqy a8e0584
chore: changelog
ymqy 9ecbb59
chore: update changelog
ymqy d4f62c0
chore: fix ci
ymqy a423029
chore: TestEntry numPassingAsserts
ymqy cdfd96f
fix: missing numPassingAsserts
ymqy ba550ce
chore: numPassingAsserts unit test
ymqy 82e450f
chore: AssertionCountsReporter e2e test
ymqy 0418a30
chore: only test in jest-circus
ymqy 94386e1
chore: update numPassingAsserts snapshot
ymqy 249388c
chore: onNotJestJasmine helper
ymqy 8e13c11
chore: remove hard code
ymqy e5408ae
chore: rename
ymqy 2aa739f
chore: update fn name
ymqy 886a709
chore: update export
ymqy bae470a
chore: update copyright
ymqy 607bdb3
chore: use inline snapshot
ymqy 309f98d
Merge branch 'main' into feature/numPassingAsserts
SimenB d683aaf
move changelog entry
SimenB e920161
chore: remove skipTestOnJasmine
ymqy 7f2f2df
chore: customReportersOnCircus e2e test
ymqy 9d0c78a
fix: ci error
ymqy f3dff25
Merge branch 'main' into feature/numPassingAsserts
ymqy e5cac79
Update CHANGELOG.md
ymqy 565fef8
Update CHANGELOG.md
SimenB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 11 additions & 0 deletions
11
e2e/__tests__/__snapshots__/customReportersOnCircus.test.ts.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Custom Reporters Integration on jest-circus valid failing assertion counts for adding reporters 1`] = ` | ||
"onTestCaseResult: adds fail, status: failed, numExpectations: 0 | ||
onTestFileResult testCaseResult 0: adds fail, status: failed, numExpectations: 0" | ||
`; | ||
|
||
exports[`Custom Reporters Integration on jest-circus valid passing assertion counts for adding reporters 1`] = ` | ||
"onTestCaseResult: adds ok, status: passed, numExpectations: 3 | ||
onTestFileResult testCaseResult 0: adds ok, status: passed, numExpectations: 3" | ||
`; |
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,42 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import {skipSuiteOnJasmine} from '@jest/test-utils'; | ||
import runJest from '../runJest'; | ||
|
||
skipSuiteOnJasmine(); | ||
|
||
describe('Custom Reporters Integration on jest-circus', () => { | ||
test('valid passing assertion counts for adding reporters', () => { | ||
const {stdout} = runJest('custom-reporters', [ | ||
'--config', | ||
JSON.stringify({ | ||
reporters: [ | ||
'default', | ||
'<rootDir>/reporters/AssertionCountsReporter.js', | ||
], | ||
}), | ||
'add.test.js', | ||
]); | ||
|
||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
|
||
test('valid failing assertion counts for adding reporters', () => { | ||
const {stdout} = runJest('custom-reporters', [ | ||
'--config', | ||
JSON.stringify({ | ||
reporters: [ | ||
'default', | ||
'<rootDir>/reporters/AssertionCountsReporter.js', | ||
], | ||
}), | ||
'addFail.test.js', | ||
]); | ||
|
||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
}); |
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,29 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* 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; |
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should we reset it?
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.
numPassingAsserts
is reset to 0 after execution of_addExpectedAssertionErrors
, reset method is called withinjestExpect.extractExpectedAssertionsErrors
method.https://github.com/facebook/jest/blob/d683aafde24f2cf6f6cb5a0a71069fd6a0a55c36/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts#L249-L253