Skip to content

Commit 3b718bc

Browse files
committed
solution 3
1 parent 68c94d1 commit 3b718bc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/jest-runtime/src/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ class Runtime {
346346
loaded: false,
347347
};
348348
moduleRegistry[modulePath] = localModule;
349-
if (path.extname(modulePath) === '.json') {
349+
if (path.extname(modulePath.split('?')[0]) === '.json') {
350350
localModule.exports = this._environment.global.JSON.parse(
351-
stripBOM(fs.readFileSync(modulePath, 'utf8')),
351+
stripBOM(fs.readFileSync(modulePath.split('?')[0], 'utf8')),
352352
);
353353
} else if (path.extname(modulePath) === '.node') {
354354
// $FlowFixMe
@@ -422,7 +422,7 @@ class Runtime {
422422
'__mocks__',
423423
moduleFileName,
424424
);
425-
if (fs.existsSync(potentialManualMock)) {
425+
if (fs.existsSync(potentialManualMock.split('?')[0])) {
426426
isManualMock = true;
427427
modulePath = potentialManualMock;
428428
}
@@ -520,7 +520,7 @@ class Runtime {
520520
if (
521521
coveredFiles.has(sourcePath) &&
522522
this._needsCoverageMapped.has(sourcePath) &&
523-
fs.existsSync(this._sourceMapRegistry[sourcePath])
523+
fs.existsSync(this._sourceMapRegistry[sourcePath].split('?')[0])
524524
) {
525525
result[sourcePath] = this._sourceMapRegistry[sourcePath];
526526
}

packages/jest-transform/src/ScriptTransformer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export default class ScriptTransformer {
299299
const isInternalModule = !!(options && options.isInternalModule);
300300
const isCoreModule = !!(options && options.isCoreModule);
301301
const content = stripShebang(
302-
fileSource || fs.readFileSync(filename, 'utf8'),
302+
fileSource || fs.readFileSync(filename.split('?')[0], 'utf8'),
303303
);
304304

305305
let wrappedCode: string;
@@ -511,7 +511,7 @@ const readCacheFile = (cachePath: Path): ?string => {
511511
};
512512

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

0 commit comments

Comments
 (0)