Skip to content
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

Migrate jest-phabricator to TypeScript #7965

Merged
merged 4 commits into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
- `[jest-resolve-dependencies]`: Migrate to TypeScript ([#7922](https://github.com/facebook/jest/pull/7922))
- `[expect]`: Migrate to TypeScript ([#7919](https://github.com/facebook/jest/pull/7919))
- `[jest-circus]`: Migrate to TypeScript ([#7916](https://github.com/facebook/jest/pull/7916))
- `[jest-phabricator]`: Migrate to TypeScript ([#7965](https://github.com/facebook/jest/pull/7965))

### Performance

Expand Down
4 changes: 4 additions & 0 deletions packages/jest-phabricator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"url": "https://github.com/facebook/jest.git",
"directory": "packages/jest-phabricator"
},
"types": "build/index.d.ts",
"dependencies": {
"@jest/types": "^24.1.0"
},
"engines": {
"node": ">= 6"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,14 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @flow
*/

import type {
AggregatedResult,
AggregatedResultWithoutCoverage,
CoverageMap,
} from 'types/TestResult';
import {TestResult} from '@jest/types';

type PhabricatorReport = AggregatedResultWithoutCoverage & {
coverageMap?: ?CoverageMap,
};

function summarize(coverageMap: CoverageMap) {
function summarize(coverageMap: TestResult.CoverageMap) {
const summaries = Object.create(null);

coverageMap.files().forEach(file => {
coverageMap.files().forEach((file: string) => {
const covered = [];
const lineCoverage = coverageMap.fileCoverageFor(file).getLineCoverage();

Expand All @@ -41,8 +32,9 @@ function summarize(coverageMap: CoverageMap) {
return summaries;
}

module.exports = function(results: AggregatedResult): PhabricatorReport {
// $FlowFixMe: This should work, but it does not.
module.exports = function(
results: TestResult.AggregatedResult,
): TestResult.AggregatedResult {
return {
...results,
coverageMap: results.coverageMap && summarize(results.coverageMap),
Expand Down
12 changes: 12 additions & 0 deletions packages/jest-phabricator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"references": [
{
"path": "../jest-types"
}
]
}
6 changes: 3 additions & 3 deletions packages/jest-types/src/TestResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export type CoverageSummary = {
};

export type FileCoverage = {
getLineCoverage: () => Object;
getLineCoverage: () => {[line: string]: string};
getUncoveredLines: () => Array<number>;
getBranchCoverageByLine: () => Object;
toJSON: () => Object;
getBranchCoverageByLine: () => {[line: string]: string};
toJSON: () => {[line: string]: string};
merge: (other: Object) => undefined;
computeSimpleTotals: (property: string) => FileCoverageTotal;
computeBranchTotals: () => FileCoverageTotal;
Expand Down