Skip to content

Commit

Permalink
chore: fix mobile jest tests with solana libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Justkant committed Nov 12, 2024
1 parent cddb163 commit eb701e8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/ledger-live-mobile/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = {
{ outputName: "llm-sonar-executionTests-report.xml", reportedFilePath: "absolute" },
],
],
resolver: "<rootDir>/scripts/resolver.js",
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths),
"^react$": "<rootDir>/node_modules/react",
Expand Down
27 changes: 27 additions & 0 deletions apps/ledger-live-mobile/scripts/resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 => {
const pkgNamesToTarget = new Set([
"rpc-websockets",
"@solana/codecs",
"@solana/codecs-core",
"@solana/errors",
"@solana/codecs-data-structures",
"@solana/codecs-numbers",
"@solana/codecs-strings",
"@solana/options",
]);

if (pkgNamesToTarget.has(pkg.name)) {
// console.log('>>>', pkg.name)
delete pkg["exports"];
delete pkg["module"];
}

return pkg;
},
});
};

0 comments on commit eb701e8

Please sign in to comment.