Skip to content

Commit

Permalink
Migrate jest-phabricator to TypeScript (#7965)
Browse files Browse the repository at this point in the history
  • Loading branch information
r3nya authored and SimenB committed Feb 23, 2019
1 parent 481334b commit 9a8cafe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
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
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
Expand Up @@ -3,20 +3,11 @@
*
* 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 => {
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
@@ -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
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

0 comments on commit 9a8cafe

Please sign in to comment.