Skip to content

Commit 3ed57c8

Browse files
committed
solution 3
1 parent 57db73f commit 3ed57c8

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
@@ -329,9 +329,9 @@ class Runtime {
329329
loaded: false,
330330
};
331331
moduleRegistry[modulePath] = localModule;
332-
if (path.extname(modulePath) === '.json') {
332+
if (path.extname(modulePath.split('?')[0]) === '.json') {
333333
localModule.exports = this._environment.global.JSON.parse(
334-
stripBOM(fs.readFileSync(modulePath, 'utf8')),
334+
stripBOM(fs.readFileSync(modulePath.split('?')[0], 'utf8')),
335335
);
336336
} else if (path.extname(modulePath) === '.node') {
337337
// $FlowFixMe
@@ -391,7 +391,7 @@ class Runtime {
391391
'__mocks__',
392392
moduleFileName,
393393
);
394-
if (fs.existsSync(potentialManualMock)) {
394+
if (fs.existsSync(potentialManualMock.split('?')[0])) {
395395
manualMock = true;
396396
modulePath = potentialManualMock;
397397
}
@@ -472,7 +472,7 @@ class Runtime {
472472
if (
473473
coveredFiles.has(sourcePath) &&
474474
this._needsCoverageMapped.has(sourcePath) &&
475-
fs.existsSync(this._sourceMapRegistry[sourcePath])
475+
fs.existsSync(this._sourceMapRegistry[sourcePath].split('?')[0])
476476
) {
477477
result[sourcePath] = this._sourceMapRegistry[sourcePath];
478478
}

packages/jest-runtime/src/script_transformer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export default class ScriptTransformer {
292292
const isInternalModule = !!(options && options.isInternalModule);
293293
const isCoreModule = !!(options && options.isCoreModule);
294294
const content = stripShebang(
295-
fileSource || fs.readFileSync(filename, 'utf8'),
295+
fileSource || fs.readFileSync(filename.split('?')[0], 'utf8'),
296296
);
297297

298298
let wrappedCode: string;
@@ -502,7 +502,7 @@ const readCacheFile = (cachePath: Path): ?string => {
502502
};
503503

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

0 commit comments

Comments
 (0)