Skip to content

Commit

Permalink
solution 3
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-leonov committed Oct 24, 2018
1 parent 57db73f commit 3ed57c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/jest-runtime/src/index.js
Expand Up @@ -329,9 +329,9 @@ class Runtime {
loaded: false,
};
moduleRegistry[modulePath] = localModule;
if (path.extname(modulePath) === '.json') {
if (path.extname(modulePath.split('?')[0]) === '.json') {
localModule.exports = this._environment.global.JSON.parse(
stripBOM(fs.readFileSync(modulePath, 'utf8')),
stripBOM(fs.readFileSync(modulePath.split('?')[0], 'utf8')),
);
} else if (path.extname(modulePath) === '.node') {
// $FlowFixMe
Expand Down Expand Up @@ -391,7 +391,7 @@ class Runtime {
'__mocks__',
moduleFileName,
);
if (fs.existsSync(potentialManualMock)) {
if (fs.existsSync(potentialManualMock.split('?')[0])) {
manualMock = true;
modulePath = potentialManualMock;
}
Expand Down Expand Up @@ -472,7 +472,7 @@ class Runtime {
if (
coveredFiles.has(sourcePath) &&
this._needsCoverageMapped.has(sourcePath) &&
fs.existsSync(this._sourceMapRegistry[sourcePath])
fs.existsSync(this._sourceMapRegistry[sourcePath].split('?')[0])
) {
result[sourcePath] = this._sourceMapRegistry[sourcePath];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-runtime/src/script_transformer.js
Expand Up @@ -292,7 +292,7 @@ export default class ScriptTransformer {
const isInternalModule = !!(options && options.isInternalModule);
const isCoreModule = !!(options && options.isCoreModule);
const content = stripShebang(
fileSource || fs.readFileSync(filename, 'utf8'),
fileSource || fs.readFileSync(filename.split('?')[0], 'utf8'),
);

let wrappedCode: string;
Expand Down Expand Up @@ -502,7 +502,7 @@ const readCacheFile = (cachePath: Path): ?string => {
};

const getScriptCacheKey = (filename, instrument: boolean) => {
const mtime = fs.statSync(filename).mtime;
const mtime = fs.statSync(filename.split('?')[0]).mtime;
return filename + '_' + mtime.getTime() + (instrument ? '_instrumented' : '');
};

Expand Down

0 comments on commit 3ed57c8

Please sign in to comment.