Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix flow violations and minimize diff
  • Loading branch information
SimenB committed Feb 18, 2018
commit 765f78a758ac7cdb41f1aba46344ca842ff23678
7 changes: 2 additions & 5 deletions packages/jest-jasmine2/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ async function jasmine2(

if (sourceMapSource) {
try {
const sourceMap = fs.readFileSync(sourceMapSource, 'utf8');
return {
map: JSON.parse(sourceMap),
map: JSON.parse(fs.readFileSync(sourceMapSource)),
url: source,
};
} catch (e) {
// ignore
}
} catch (e) {}
}
return null;
},
Expand Down
13 changes: 11 additions & 2 deletions packages/jest-util/src/get_callsite.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
/**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rickhanlonii would you mind adding a couple of unit tests to this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will do

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* 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 {SourceMapRegistry} from 'types/SourceMaps';

import fs from 'fs';
import fs from 'graceful-fs';
import callsites from 'callsites';
import {SourceMapConsumer} from 'source-map';

Expand Down Expand Up @@ -37,7 +46,7 @@ const addSourceMapConsumer = (callsite, consumer) => {
});
};

export default (level: number, sourceMaps?: SourceMapRegistry) => {
export default (level: number, sourceMaps: ?SourceMapRegistry) => {
const levelAfterThisCall = level + 1;
const stack = callsites()[levelAfterThisCall];
const sourceMapFileName = sourceMaps && sourceMaps[stack.getFileName()];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either add a ? to the type declaration, or drop the sourceMaps && part

Expand Down