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

fix: async tests in Mocha #667

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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
6 changes: 6 additions & 0 deletions qase-mocha/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [email protected]

## What's new

Fixed the issue with async tests not being reported correctly.

# [email protected]

## What's new
Expand Down
2 changes: 1 addition & 1 deletion qase-mocha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mocha-qase-reporter",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "Mocha Cypress Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"sideEffects": false,
Expand Down
8 changes: 5 additions & 3 deletions qase-mocha/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
this.runner.on(Events.EVENT_HOOK_BEGIN, (hook: Hook) => this.addMethods(hook.ctx));

this.runner.on(Events.EVENT_TEST_BEGIN, () => this.onStartTest());
this.runner.on(Events.EVENT_TEST_END, (test) => this.onEndTest(test));
// eslint-disable-next-line @typescript-eslint/no-misused-promises
this.runner.on(Events.EVENT_TEST_END, async (test) => await this.onEndTest(test));
};

private onStartRun() {
Expand Down Expand Up @@ -116,7 +117,7 @@
this.currentType = 'test';
}

private onEndTest(test: Mocha.Test) {
private async onEndTest(test: Mocha.Test) {
if (this.metadata.ignore) {
return;
}
Expand Down Expand Up @@ -172,7 +173,8 @@
title: this.metadata.title && this.metadata.title != '' ? this.metadata.title : test.title,
};

deasyncPromise(this.reporter.addTestResult(result));
await this.reporter.addTestResult(result);

this.metadata.clear();
this.currentTest = new currentTest();
}
Expand All @@ -188,7 +190,7 @@

if (file) {
const executionPath = process.cwd() + '/';
const path = file.replace(executionPath, '') ?? '';

Check warning on line 193 in qase-mocha/src/reporter.ts

View workflow job for this annotation

GitHub Actions / Project qase-mocha - Node 16

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined

Check warning on line 193 in qase-mocha/src/reporter.ts

View workflow job for this annotation

GitHub Actions / Project qase-mocha - Node 16

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined

Check warning on line 193 in qase-mocha/src/reporter.ts

View workflow job for this annotation

GitHub Actions / Project qase-mocha - Node 18

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined

Check warning on line 193 in qase-mocha/src/reporter.ts

View workflow job for this annotation

GitHub Actions / Project qase-mocha - Node 18

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
signature = path.split('/').join('::');
}

Expand Down
Loading