Skip to content

Add functionality to determine test coverage #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ GENESYSCLOUD_OAUTHCLIENT_ID
GENESYSCLOUD_OAUTHCLIENT_SECRET`,
false,
)
.option('-cov --coverage', 'Capture test coverage. Requires --associate-id setting being set')
.option('-fo, --failures-only', 'Only output failures', false)
.option(
'-t, --timeout <number>',
Expand All @@ -121,6 +122,7 @@ GENESYSCLOUD_OAUTHCLIENT_SECRET`,
deploymentId?: string;
region?: string;
origin?: string;
coverage?: boolean;
timeout: number;
},
) => {
Expand All @@ -129,6 +131,11 @@ GENESYSCLOUD_OAUTHCLIENT_SECRET`,
throw new Error('No writeOut and/or writeErr');
}

if (options.coverage && !options.associateId) {
outputConfig.writeErr(ui.coverageRequiresAssociateIdOption());
throw new CommandExpectedlyFailedError();
}

let associateId: { enabled: false } | { enabled: true; client: MessageIdToConvoIdClient };
if (!options.associateId) {
associateId = { enabled: false };
Expand Down Expand Up @@ -325,6 +332,8 @@ GENESYSCLOUD_OAUTHCLIENT_SECRET`,
ui.testScriptSummary([...scenariosThatPassed, ...scenariosThatFailed]),
);

// Work out coverage here

if (results.scenarioResults.some((r) => !r.hasPassed)) {
throw new CommandExpectedlyFailedError();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test('test', () => {});
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export class Ui {
return Ui.trailingNewline(chalk.red(error?.message ?? 'Failed to validate Session config'));
}

public coverageRequiresAssociateIdOption(): string {
return Ui.trailingNewline(
chalk.red('The --coverage option requires the --associate-id option to be set.'),
);
}

public preflightCheckOfAssociateConvoIdFailed(error: PreflightError): string {
if (error.errorType === 'missing-permissions') {
return Ui.trailingNewline(
Expand Down