kafka-ui/kafka-ui-react-app/.jest/resolver.js
Oleg Shur c4f97327c0
Make frontend work properly with custom context url (#2363)
* Add an ability to run app from subfolder

* linting

* Fix all the static resources URLs and manifest.json

Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>
2022-08-01 20:47:49 +04:00

26 lines
1.1 KiB
JavaScript

module.exports = (path, options) => {
// Call the defaultResolver, so we leverage its cache, error handling, etc.
return options.defaultResolver(path, {
...options,
// Use packageFilter to process parsed `package.json` before
// the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb)
packageFilter: (pkg) => {
// jest-environment-jsdom 28+ tries to use browser exports instead of default exports,
// but @hookform/resolvers only offers an ESM browser export and not a CommonJS one. Jest does not yet
// support ESM modules natively, so this causes a Jest error related to trying to parse
// "export" syntax.
//
// This workaround prevents Jest from considering @hookform/resolvers module-based exports at all;
// it falls back to CommonJS+node "main" property.
if (pkg.name === '@hookform/resolvers') {
delete pkg['exports'];
delete pkg['module'];
}
if (pkg.name === 'jsonpath-plus') {
delete pkg['exports'];
delete pkg['module'];
}
return pkg;
},
});
};