Skip to content
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

Suite name #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 2 additions & 9 deletions packages/reporter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ export class VisualRegressionReport {
});
}

saveTestContext(context: any): void {
const { passed, testName } = this.transformContext(context);

this.lastTestCase = { ...this.lastTestCase, passed, testName };
saveTestContext(context: Partial<TestContextResult>): void {
this.lastTestCase = { ...this.lastTestCase, ...context };
this.report.push(this.lastTestCase as ReportData);
this.lastTestCase = { matchers: [] };
}
Expand All @@ -55,9 +53,4 @@ export class VisualRegressionReport {
unlinkSync(report);
}
}

private transformContext(context: any): Partial<TestContextResult> {
// TODO: Tested with mocha and jasmine
return { testName: context.title, passed: context.passed };
}
}
1 change: 1 addition & 0 deletions packages/reporter/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface MatchCommandResult {
export type TestContextResult = Omit<ReportData, 'matchers'>;

export interface ReportData {
suiteName: string;
testName: string;
passed: boolean;
matchers: MatchCommandResult[];
Expand Down
22 changes: 21 additions & 1 deletion packages/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,27 @@ export class VisualRegression {
}

afterTest(context: any) {
this.report.saveTestContext(context);
const testName = context.title;
let suiteName = '';
// TODO: Tested with jasmine
if (context.fullTitle.endsWith(testName)) {
suiteName = context.fullTitle.substr(0, context.fullTitle.length - testName.length).trim();
}

// TODO: Tested with mocha and jasmine
this.report.saveTestContext({
suiteName,
testName,
passed: context.passed
});
}

afterScenario(uri: string, feature: any, scenario: any, result: any) {
this.report.saveTestContext({
suiteName: feature.document.feature.name,
testName: scenario.name,
passed: result.status === 'passed'
});
}

after() {
Expand Down