Skip to content

Commit

Permalink
Migrate jest-phabricator to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
r3nya committed Feb 23, 2019
1 parent e998c92 commit 06d20a9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 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,23 +3,22 @@
*
* 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 {
import {
AggregatedResult,
AggregatedResultWithoutCoverage,
CoverageMap,
} from 'types/TestResult';
} from '@jest/types';

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

function summarize(coverageMap: 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 @@ -42,7 +41,6 @@ function summarize(coverageMap: CoverageMap) {
}

module.exports = function(results: AggregatedResult): PhabricatorReport {
// $FlowFixMe: This should work, but it does not.
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"
}
]
}

0 comments on commit 06d20a9

Please sign in to comment.