Skip to content

Commit

Permalink
add some flow types
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbay committed Dec 15, 2016
1 parent 6471a7b commit 08e134f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/jest-cli/src/reporters/CoverageReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class CoverageReporter extends BaseReporter {
) {
if (testResult.coverage) {
this._coverageMap.merge(testResult.coverage);

// Remove coverage data to free up some memory.
delete testResult.coverage;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const generateEmptyCoverage = (
const transform = getTransformer(filename, config);
let source = content;

if (shouldTransform(filename, config)) {
if (transform && shouldTransform(filename, config)) {
if (
transform.canInstrument &&
typeof transform.getEmptyCoverage === 'function'
Expand Down
29 changes: 29 additions & 0 deletions types/Transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@

import type {Config, Path} from 'types/Config';

export type SourceMap = {|
file: string,
mappings: string,
names: string[],
sourceRoot: string,
sources: string[],
sourcesContent: string[],
version: number,
|};

export type Coverage = {|
path: string,
s: { [statementId: number]: number },
b: { [branchId: number]: number },
f: { [functionId: number]: number },
l: { [lineId: number]: number },
fnMap: { [functionId: number]: any },
statementMap: { [statementId: number]: any },
branchMap: { [branchId: number]: any },
inputSourceMap: ?SourceMap,
|}

export type TransformOptions = {|
instrument: boolean,
watch: boolean,
Expand All @@ -32,4 +54,11 @@ export type Transformer = {|
config: Config,
options?: TransformOptions,
) => string,

getEmptyCoverage: (
sourceText: string,
sourcePath: Path,
config: Config,
options?: TransformOptions,
) => Coverage
|};

0 comments on commit 08e134f

Please sign in to comment.