Skip to content

Commit 4040368

Browse files
committed
solution 3
1 parent c9481ac commit 4040368

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/jest-runtime/src/ScriptTransformer.js

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

307307
let wrappedCode: string;
@@ -513,7 +513,7 @@ const readCacheFile = (cachePath: Path): ?string => {
513513
};
514514

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

packages/jest-runtime/src/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ class Runtime {
343343
loaded: false,
344344
};
345345
moduleRegistry[modulePath] = localModule;
346-
if (path.extname(modulePath) === '.json') {
346+
if (path.extname(modulePath.split('?')[0]) === '.json') {
347347
localModule.exports = this._environment.global.JSON.parse(
348-
stripBOM(fs.readFileSync(modulePath, 'utf8')),
348+
stripBOM(fs.readFileSync(modulePath.split('?')[0], 'utf8')),
349349
);
350350
} else if (path.extname(modulePath) === '.node') {
351351
// $FlowFixMe
@@ -413,7 +413,7 @@ class Runtime {
413413
'__mocks__',
414414
moduleFileName,
415415
);
416-
if (fs.existsSync(potentialManualMock)) {
416+
if (fs.existsSync(potentialManualMock.split('?')[0])) {
417417
manualMock = true;
418418
modulePath = potentialManualMock;
419419
}
@@ -511,7 +511,7 @@ class Runtime {
511511
if (
512512
coveredFiles.has(sourcePath) &&
513513
this._needsCoverageMapped.has(sourcePath) &&
514-
fs.existsSync(this._sourceMapRegistry[sourcePath])
514+
fs.existsSync(this._sourceMapRegistry[sourcePath].split('?')[0])
515515
) {
516516
result[sourcePath] = this._sourceMapRegistry[sourcePath];
517517
}

0 commit comments

Comments
 (0)