Skip to content

Commit

Permalink
chore: reword passed to success
Browse files Browse the repository at this point in the history
  • Loading branch information
puskuruk committed Jul 18, 2022
1 parent 277e327 commit 1578c5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/CLIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Result = {
startedAt: Date;
file: string;
finishedAt: Date;
passed: boolean;
success: boolean;
title: string;
};

Expand Down Expand Up @@ -116,9 +116,9 @@ export function createStatusReport(results: Result[]): Table.Table {

const duration =
result.finishedAt?.getTime()! - result.startedAt.getTime() || 0;
const status = result.passed
? resultTextColor.bgGreen(' Passed ')
: resultTextColor.bgRed(' Failed ');
const status = result.success
? resultTextColor.bgGreen(' Success ')
: resultTextColor.bgRed(' Failure ');

row.push(result.title);
row.push(status);
Expand All @@ -134,7 +134,7 @@ export function createStatusReport(results: Result[]): Table.Table {
export async function runFiles(
files: string[],
opts: { log: boolean; headless: boolean | 'chrome'; extension?: string } = {
log: false,
log: true,
headless: true,
}
): Promise<void> {
Expand All @@ -159,7 +159,7 @@ export async function runFiles(
startedAt: new Date(),
finishedAt: new Date(),
file,
passed: true,
success: true,
};

opts.log && console.log(`Running ${file}...`);
Expand All @@ -180,7 +180,7 @@ export async function runFiles(
opts.log && console.log(`Finished running ${file}`);
} catch (err) {
opts.log && console.error(`Error running ${file}`, err);
result.passed = false;
result.success = false;
} finally {
result.finishedAt = new Date();
results.push(result);
Expand All @@ -194,7 +194,7 @@ export async function runFiles(
console.log(statusReport.toString());
}

if (results.every((result) => result.passed)) return;
if (results.every((result) => result.success)) return;

throw new Error('Some recordings have failed to run.');
}
8 changes: 4 additions & 4 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ describe('cli', () => {
startedAt: date,
file: path.join(__dirname, 'resources', 'replay-fail.json'),
finishedAt: new Date(date.getTime() + 1000),
passed: true,
success: true,
title: 'Test run',
};
const [statusReport] = createStatusReport([result]);
const [title, status, file, duration] =
statusReport as HorizontalTableRow;

assert.strictEqual(status, colors.white.bgGreen(' Passed '));
assert.strictEqual(status, colors.white.bgGreen(' Success '));
assert.strictEqual(duration, '1000ms');
assert.isString(file);
assert.strictEqual(title, result.title);
Expand All @@ -144,14 +144,14 @@ describe('cli', () => {
startedAt: date,
file: path.join(__dirname, 'resources', 'replay-fail.json'),
finishedAt: date,
passed: false,
success: false,
title: 'Test run',
};
const [statusReport] = createStatusReport([result]);
const [title, status, file, duration] =
statusReport as HorizontalTableRow;

assert.strictEqual(status, colors.white.bgRed(' Failed '));
assert.strictEqual(status, colors.white.bgRed(' Failure '));
assert.strictEqual(duration, '0ms');
assert.isString(file);
assert.strictEqual(title, result.title);
Expand Down

0 comments on commit 1578c5d

Please sign in to comment.