diff --git a/packages/jest-runtime/src/index.js b/packages/jest-runtime/src/index.js index 8adede5ec442..a9d850fd56c7 100644 --- a/packages/jest-runtime/src/index.js +++ b/packages/jest-runtime/src/index.js @@ -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 @@ -391,7 +391,7 @@ class Runtime { '__mocks__', moduleFileName, ); - if (fs.existsSync(potentialManualMock)) { + if (fs.existsSync(potentialManualMock.split('?')[0])) { manualMock = true; modulePath = potentialManualMock; } @@ -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]; } diff --git a/packages/jest-runtime/src/script_transformer.js b/packages/jest-runtime/src/script_transformer.js index 96014c5ba088..81f94b17c80c 100644 --- a/packages/jest-runtime/src/script_transformer.js +++ b/packages/jest-runtime/src/script_transformer.js @@ -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; @@ -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' : ''); };