-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
numPassingAsserts
of testCaseResult (#13795)
- Loading branch information
Showing
14 changed files
with
129 additions
and
2 deletions.
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