fix(testing): correctly error with jest.mock for invalid filepaths (#15445)
This commit is contained in:
parent
454344b1ef
commit
083f4f12c8
@ -1,4 +1,4 @@
|
|||||||
import { dirname, extname } from 'path';
|
import { dirname, extname, join } from 'path';
|
||||||
import { resolve as resolveExports } from 'resolve.exports';
|
import { resolve as resolveExports } from 'resolve.exports';
|
||||||
import type defaultResolver from 'jest-resolve/build/defaultResolver';
|
import type defaultResolver from 'jest-resolve/build/defaultResolver';
|
||||||
|
|
||||||
@ -81,7 +81,11 @@ module.exports = function (path: string, options: ResolveOptions) {
|
|||||||
ts = ts || require('typescript');
|
ts = ts || require('typescript');
|
||||||
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
|
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
|
||||||
const { compilerOptions, host } = compilerSetup;
|
const { compilerOptions, host } = compilerSetup;
|
||||||
return ts.resolveModuleName(path, options.basedir, compilerOptions, host)
|
return ts.resolveModuleName(
|
||||||
.resolvedModule.resolvedFileName;
|
path,
|
||||||
|
join(options.basedir, 'fake-placeholder.ts'),
|
||||||
|
compilerOptions,
|
||||||
|
host
|
||||||
|
).resolvedModule.resolvedFileName;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -91,7 +91,11 @@ module.exports = function (path, options) {
|
|||||||
} else if (path === '@nrwl/devkit/testing') {
|
} else if (path === '@nrwl/devkit/testing') {
|
||||||
return join(__dirname, '../', './packages/devkit/testing.js');
|
return join(__dirname, '../', './packages/devkit/testing.js');
|
||||||
}
|
}
|
||||||
return ts.resolveModuleName(path, options.basedir, compilerOptions, host)
|
return ts.resolveModuleName(
|
||||||
.resolvedModule.resolvedFileName;
|
path,
|
||||||
|
join(options.basedir, 'fake-placeholder.ts'),
|
||||||
|
compilerOptions,
|
||||||
|
host
|
||||||
|
).resolvedModule.resolvedFileName;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user