-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjest-resolver.js
24 lines (21 loc) · 1.03 KB
/
jest-resolver.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* eslint-disable func-names */
// -------------------------------------------------------------------------------------------------
// Taken from https://github.com/typescript-eslint/typescript-eslint/blob/eaaa2047ca54f098dcdd32aaf5d8949495c6be26/tests/jest-resolver.js
// -------------------------------------------------------------------------------------------------
// temporary workaround - https://github.com/facebook/jest/issues/9771#issuecomment-871585234
const resolver = require('enhanced-resolve').create.sync({
conditionNames: ['require', 'node', 'default'],
extensions: ['.js', '.json', '.node', '.ts', '.tsx'],
});
/**
* @param request {unknown}
* @param options {{ defaultResolver(...args: unknown[]): unknown, basedir: unknown }}
* @returns {unknown}
*/
module.exports = function (request, options) {
// list global module that must be resolved by defaultResolver here
if (['fs', 'http', 'path'].includes(request)) {
return options.defaultResolver(request, options);
}
return resolver(options.basedir, request);
};