From 92847bdbc187478f246040f56bcda770414346b8 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 17 Oct 2023 13:58:07 +0300 Subject: [PATCH] [FIX] Consider configPath when autoDetectType (#617) fixes: https://github.com/SAP/karma-ui5/issues/595 --- lib/framework.js | 4 +++- test/unit/framework.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/framework.js b/lib/framework.js index 2d2b529e..5fb14121 100644 --- a/lib/framework.js +++ b/lib/framework.js @@ -302,7 +302,9 @@ export default class Framework { if (this.config.ui5.type) { return; } - const filePath = path.join(this.config.basePath, "ui5.yaml"); + const {ui5: {configPath}, basePath} = this.config; + const filePath = configPath ? + path.resolve(basePath, configPath) : path.join(basePath, "ui5.yaml"); let fileContent; try { fileContent = readFileSync(filePath); diff --git a/test/unit/framework.js b/test/unit/framework.js index 334913b7..fa42a198 100644 --- a/test/unit/framework.js +++ b/test/unit/framework.js @@ -212,6 +212,20 @@ test("UI5 Middleware / Proxy configuration: Should setup UI5 tooling middleware t.deepEqual(setupUI5Server.lastCall.args, [{basePath: "", configPath: undefined}]); }); +test("ui5.yaml: should be configurable when autoDetectType", + async (t) => { + const {framework, logger, readFileSyncStub, sinon} = t.context; + const autoDetectTypeSpy = sinon.spy(framework, "autoDetectType"); + const mockUI5YamlPath = "../ui5/yaml/ui5-custom.yaml"; + + framework.exists = () => true; + framework.init({config: {ui5: {configPath: mockUI5YamlPath}, basePath: "/alternative/app"}, logger}); + + t.true(autoDetectTypeSpy.calledOnce, "autoDetectType is called"); + t.deepEqual(readFileSyncStub.lastCall.args, [path.resolve("/alternative/app", mockUI5YamlPath)], + "Custom ui5.yaml is provided"); + }); + // Sad path test("UI5 Middleware / Proxy configuration: Should throw if ui5.yaml is missing and no url is configured", async (t) => {