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 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,25 +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 {
AggregatedResult,
AggregatedResultWithoutCoverage,
CoverageMap,
} from 'types/TestResult';
import {TestResult} from '@jest/types';

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

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();
const lineCoverage: any = coverageMap
SimenB marked this conversation as resolved.
Show resolved Hide resolved
.fileCoverageFor(file)
.getLineCoverage();

Object.keys(lineCoverage).forEach(lineNumber => {
// Line numbers start at one
Expand All @@ -41,8 +38,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,
): PhabricatorReport {
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"
}
]
}