backend-common: tweak package path resolution mock API

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-10-05 13:19:57 +02:00
parent b074053375
commit 289c224640
4 changed files with 53 additions and 31 deletions
@@ -22,22 +22,12 @@ import {
} from '@backstage/backend-test-utils';
import { appPlugin } from './appPlugin';
import { createRootLogger } from '@backstage/backend-common';
import { overridePackagePathResolution } from '@backstage/backend-common/testUtils';
const mockDir = createMockDirectory();
jest.mock('../../../../packages/backend-common/src/paths', () => {
const actual = jest.requireActual(
'../../../../packages/backend-common/src/paths',
);
return {
...actual,
resolvePackagePath: (pkg: string, ...args: string[]) => {
if (pkg === 'app') {
return mockDir.resolve(...args);
}
return actual.resolvePackagePath(pkg, ...args);
},
};
overridePackagePathResolution({
packageName: 'app',
path: mockDir.path,
});
// Make sure root logger is initialized ahead of FS mock