From deded77b84c3976a1252b85e4d09beb84dfb9035 Mon Sep 17 00:00:00 2001 From: Hermione Dadheech Date: Sat, 25 Feb 2023 15:17:42 +0530 Subject: [PATCH 1/3] feat(mock.ts, keploy.ts, client.ts): adding Keploy Mode in logs to notify user Adding Keploy mode in logs to notify user in which mode keploy is running whether it is record, test, off feat #45 Signed-off-by: Hermione Dadheech --- mock/mock.ts | 2 ++ src/client.ts | 1 + src/keploy.ts | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mock/mock.ts b/mock/mock.ts index 3c8cfc9..d80208c 100644 --- a/mock/mock.ts +++ b/mock/mock.ts @@ -36,6 +36,7 @@ export function NewContext(conf: Config) { } catch (err) { console.log("Failed to get the path of current directory"); console.log(err); + console.log("Keploy mode:",process.env.KEPLOY_MODE) } } else if (path[0] !== "/") { try { @@ -43,6 +44,7 @@ export function NewContext(conf: Config) { } catch (err) { console.log("Failed to get the absolute path from relative conf.path"); console.log(err); + console.log("Keploy mode:",process.env.KEPLOY_MODE) } } path += "/mocks"; diff --git a/src/client.ts b/src/client.ts index b41cb82..ca26e26 100644 --- a/src/client.ts +++ b/src/client.ts @@ -142,6 +142,7 @@ export default class HttpClient { await http(options); } catch (error) { console.log(error); + console.log("Keploy mode:",process.env.KEPLOY_MODE); } } } diff --git a/src/keploy.ts b/src/keploy.ts index 1de2cca..db975df 100644 --- a/src/keploy.ts +++ b/src/keploy.ts @@ -132,7 +132,7 @@ export default class Keploy { async runTests() { if (process.env.KEPLOY_MODE == "test") { - console.log("test starting in " + this.appConfig.delay + "s"); + console.log("test starting in " + this.appConfig.delay + "s" + " KEPLOY_MODE: " + process.env.KEPLOY_MODE ); setTimeout(async () => { await this.test(); }, this.appConfig.delay * 1000); @@ -241,6 +241,8 @@ export default class Keploy { testId, " }, { total tests: ", totalTests, + " },{ Keploy mode:", + process.env.KEPLOY_MODE, " }" ); let pass = true; @@ -276,8 +278,10 @@ export default class Keploy { if (err !== null) { console.error( "failed to call test method of keploy. error: ", - err - ); + err, + "Keploy mode:", + process.env.KEPLOY_MODE, + ); } if (response?.pass?.pass === false) { From 9b70a7670e0f59775cbe711eef0c7db129d02e12 Mon Sep 17 00:00:00 2001 From: Hermione Dadheech Date: Wed, 1 Mar 2023 23:55:12 +0530 Subject: [PATCH 2/3] feat(keploy.ts, mock.ts): adding log in Keploy.ts and mock.ts feat #45 Signed-off-by: Hermione Dadheech --- mock/mock.ts | 3 +-- src/client.ts | 1 - src/keploy.ts | 9 +++------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/mock/mock.ts b/mock/mock.ts index d80208c..c3592d2 100644 --- a/mock/mock.ts +++ b/mock/mock.ts @@ -27,6 +27,7 @@ export interface Config { Mode: string; } export function NewContext(conf: Config) { + console.log("Keploy running in: ",process.env.KEPLOY_MODE," mode"); let mode = MODE_TEST, path = conf !== undefined && conf.Path !== undefined ? conf.Path : ""; @@ -36,7 +37,6 @@ export function NewContext(conf: Config) { } catch (err) { console.log("Failed to get the path of current directory"); console.log(err); - console.log("Keploy mode:",process.env.KEPLOY_MODE) } } else if (path[0] !== "/") { try { @@ -44,7 +44,6 @@ export function NewContext(conf: Config) { } catch (err) { console.log("Failed to get the absolute path from relative conf.path"); console.log(err); - console.log("Keploy mode:",process.env.KEPLOY_MODE) } } path += "/mocks"; diff --git a/src/client.ts b/src/client.ts index ca26e26..b41cb82 100644 --- a/src/client.ts +++ b/src/client.ts @@ -142,7 +142,6 @@ export default class HttpClient { await http(options); } catch (error) { console.log(error); - console.log("Keploy mode:",process.env.KEPLOY_MODE); } } } diff --git a/src/keploy.ts b/src/keploy.ts index db975df..3624335 100644 --- a/src/keploy.ts +++ b/src/keploy.ts @@ -76,6 +76,7 @@ export default class Keploy { this.responses = {}; this.dependencies = {}; this.mocks = {}; + console.log("Keploy running in: ",process.env.KEPLOY_MODE," mode"); } validateServerConfig({ @@ -132,7 +133,7 @@ export default class Keploy { async runTests() { if (process.env.KEPLOY_MODE == "test") { - console.log("test starting in " + this.appConfig.delay + "s" + " KEPLOY_MODE: " + process.env.KEPLOY_MODE ); + console.log("test starting in " + this.appConfig.delay + "s"); setTimeout(async () => { await this.test(); }, this.appConfig.delay * 1000); @@ -241,8 +242,6 @@ export default class Keploy { testId, " }, { total tests: ", totalTests, - " },{ Keploy mode:", - process.env.KEPLOY_MODE, " }" ); let pass = true; @@ -278,9 +277,7 @@ export default class Keploy { if (err !== null) { console.error( "failed to call test method of keploy. error: ", - err, - "Keploy mode:", - process.env.KEPLOY_MODE, + err ); } From 1ad2d591dc9a1dd7703d55d774076e06fbc00889 Mon Sep 17 00:00:00 2001 From: Hermione Dadheech Date: Fri, 3 Mar 2023 01:57:30 +0530 Subject: [PATCH 3/3] feat: changing log position in mock.ts feat #45 Signed-off-by: Hermione Dadheech --- mock/mock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock/mock.ts b/mock/mock.ts index c3592d2..979876c 100644 --- a/mock/mock.ts +++ b/mock/mock.ts @@ -27,7 +27,6 @@ export interface Config { Mode: string; } export function NewContext(conf: Config) { - console.log("Keploy running in: ",process.env.KEPLOY_MODE," mode"); let mode = MODE_TEST, path = conf !== undefined && conf.Path !== undefined ? conf.Path : ""; @@ -60,6 +59,7 @@ export function NewContext(conf: Config) { if (Mode.Valid(conf.Mode)) { mode = conf.Mode; } + console.log("Keploy running in: ",mode," mode"); switch (mode) { case "test": if (conf.Name === "") {