Skip to content

Commit

Permalink
add logging for replacing mock API
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Oct 19, 2023
1 parent 58ffed6 commit 809355f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ const config = {
resolveRequest: (context, moduleName, platform) => {
const resolution = context.resolveRequest(context, moduleName, platform);
if (isUsingMockAPI && moduleName.includes('/API')) {
const originalPath = resolution.filePath;
const mockPath = originalPath.replace('src/libs/API.ts', 'src/libs/E2E/API.mock.js').replace('/src/libs/API.js/', 'src/libs/E2E/API.mock.js');
console.debug('> Replace', originalPath, ' => ', mockPath);

return {
...resolution,
// TODO: Change API.mock.js extension once it is migrated to TypeScript
filePath: resolution.filePath.replace(/src\/libs\/API.ts/, 'src/libs/E2E/API.mock.js').replace(/src\/libs\/API.js/, 'src/libs/E2E/API.mock.js'),
filePath: mockPath,
};
}
return resolution;
Expand Down

0 comments on commit 809355f

Please sign in to comment.