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

perf: optimize getAllAttach function #53

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 12 additions & 4 deletions src/plugins/allure-reporter-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
}

const group = this.currentGroup;
const test = group!.startTest(title);

Check warning on line 643 in src/plugins/allure-reporter-plugin.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion

Check warning on line 643 in src/plugins/allure-reporter-plugin.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion

allTests.push({ specRelative: this.currentSpec?.relative, fullTitle, mochaId: id, uuid: test.uuid }); // to show warning
this.tests.push(test);
Expand Down Expand Up @@ -733,7 +733,7 @@
}
}

endTest(arg: AllureTaskArgs<'testEnded'>): { test: string; attachments: any[] } | undefined {

Check warning on line 736 in src/plugins/allure-reporter-plugin.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 736 in src/plugins/allure-reporter-plugin.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const { result, details } = arg;
const storedStatus = this.testStatusStored;
const storedDetails = this.testDetailsStored;
Expand Down Expand Up @@ -774,11 +774,19 @@
if (!this.currentTest) {
return [];
}
item.steps.forEach(step => {
res.push(...getAllAttach(res, step));
});

return [...res, ...item.attachments];
const inner = (steps: ExecutableItem[], accumulatedRes: Attachment[]) => {

Check failure on line 778 in src/plugins/allure-reporter-plugin.ts

View workflow job for this annotation

GitHub Actions / build

'inner' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
if (steps.length === 0) {
return accumulatedRes;
}

const [first, ...rest] = steps;
const newRes = [...accumulatedRes, ...first.attachments];

return inner(rest, newRes);
};

return inner(item.steps, res);
};
const resAtt: Attachment[] = [...this.currentTest.wrappedItem.attachments];
const attachments = getAllAttach(resAtt, this.currentTest.wrappedItem);
Expand Down
Loading