Skip to content

Commit

Permalink
fix: resolve scenario file relative to project's root
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Jun 6, 2023
1 parent fe61621 commit e55ffde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/TestScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export class TestScenario {
for (const key of Object.keys(this.handlers) as Array<keyof typeof this.handlers>) {
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;
Expand Down Expand Up @@ -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();
});
Expand Down
9 changes: 5 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,19 @@ 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);
}

const eventManager = new EventManager();
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
);
Expand Down

0 comments on commit e55ffde

Please sign in to comment.