Skip to content

Commit e55ffde

Browse files
committed
fix: resolve scenario file relative to project's root
1 parent fe61621 commit e55ffde

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/TestScenario.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export class TestScenario {
9090
for (const key of Object.keys(this.handlers) as Array<keyof typeof this.handlers>) {
9191
if (key in step) {
9292
const value = step[key];
93-
console.log('running handler for ' + key);
9493
void this.handlers[key](value as any, step);
9594
this.stepIndex++;
9695
return;
@@ -126,7 +125,7 @@ export class TestScenario {
126125
delay: async (value: string, step: IStepDefinition) => {
127126
const nanos = parseTime(value);
128127
const targetNanos = (this.client?.lastNanos ?? 0) + nanos;
129-
this.log(chalk`delay {yellow "${value}"}`);
128+
this.log(chalk`delay {yellow ${value}}`);
130129
this.eventManager.at(targetNanos, () => {
131130
void this.nextStep();
132131
});

src/main.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,19 @@ async function main() {
9797

9898
const chips = loadChips(config.chip ?? [], rootDir);
9999

100-
if (scenarioFile && !existsSync(scenarioFile)) {
101-
console.error(`Error: scenario file not found: ${path.resolve(scenarioFile)}`);
100+
const resolvedScenarioFile = scenarioFile ? path.resolve(rootDir, scenarioFile) : null;
101+
if (resolvedScenarioFile && !existsSync(resolvedScenarioFile)) {
102+
console.error(`Error: scenario file not found: ${path.resolve(resolvedScenarioFile)}`);
102103
process.exit(1);
103104
}
104105

105106
const eventManager = new EventManager();
106107
const expectEngine = new ExpectEngine();
107108

108109
let scenario;
109-
if (scenarioFile) {
110+
if (resolvedScenarioFile) {
110111
scenario = new TestScenario(
111-
YAML.parse(readFileSync(scenarioFile, 'utf-8')),
112+
YAML.parse(readFileSync(resolvedScenarioFile, 'utf-8')),
112113
eventManager,
113114
expectEngine
114115
);

0 commit comments

Comments
 (0)