From e55ffde20f0cfc118abd5299fc9018ac6da4d849 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Wed, 7 Jun 2023 00:51:58 +0300 Subject: [PATCH] fix: resolve scenario file relative to project's root --- src/TestScenario.ts | 3 +-- src/main.ts | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/TestScenario.ts b/src/TestScenario.ts index 2cec1b3..b0d8c3a 100644 --- a/src/TestScenario.ts +++ b/src/TestScenario.ts @@ -90,7 +90,6 @@ export class TestScenario { for (const key of Object.keys(this.handlers) as Array) { if (key in step) { const value = step[key]; - console.log('running handler for ' + key); void this.handlers[key](value as any, step); this.stepIndex++; return; @@ -126,7 +125,7 @@ export class TestScenario { delay: async (value: string, step: IStepDefinition) => { const nanos = parseTime(value); const targetNanos = (this.client?.lastNanos ?? 0) + nanos; - this.log(chalk`delay {yellow "${value}"}`); + this.log(chalk`delay {yellow ${value}}`); this.eventManager.at(targetNanos, () => { void this.nextStep(); }); diff --git a/src/main.ts b/src/main.ts index a0f0538..bee04e1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -97,8 +97,9 @@ async function main() { const chips = loadChips(config.chip ?? [], rootDir); - if (scenarioFile && !existsSync(scenarioFile)) { - console.error(`Error: scenario file not found: ${path.resolve(scenarioFile)}`); + const resolvedScenarioFile = scenarioFile ? path.resolve(rootDir, scenarioFile) : null; + if (resolvedScenarioFile && !existsSync(resolvedScenarioFile)) { + console.error(`Error: scenario file not found: ${path.resolve(resolvedScenarioFile)}`); process.exit(1); } @@ -106,9 +107,9 @@ async function main() { const expectEngine = new ExpectEngine(); let scenario; - if (scenarioFile) { + if (resolvedScenarioFile) { scenario = new TestScenario( - YAML.parse(readFileSync(scenarioFile, 'utf-8')), + YAML.parse(readFileSync(resolvedScenarioFile, 'utf-8')), eventManager, expectEngine );