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

SlackReporter Silent Failure onComplete #37

Open
ChandlerFerry opened this issue May 13, 2024 · 0 comments
Open

SlackReporter Silent Failure onComplete #37

ChandlerFerry opened this issue May 13, 2024 · 0 comments

Comments

@ChandlerFerry
Copy link

Problem

Trying to post a custom message with SlackReporter.postMessage() in the WDIO onComplete block while using the mocha framework with bdd causes the message to silently not be posted.

after, afterSession, afterSuite, etc. all function as expected.

Code

    onComplete: function () {
        console.log('aaaa');
        return new Promise((resolve, reject) => {
            SlackReporter.postMessage({
                channel: process.env.SLACK_CHANNEL,
                slackBotToken: process.env.SLACK_BOT_TOKEN,
                text: 'testing onComplete', // Never gets sent
            })
                .then(() => {
                    console.log('ssss'); // Never Fires
                    resolve('');
                })
                .catch(() => {
                    console.log('dddd'); // Never Fires
                    reject();
                });
        });
    },

Suboptimal Workaround Solution

Use npm package @slack/web-api instead to directly send the message to slack rather than having it wrapped in this library.

Context

Mocha considers every WDIO test to be it's own suite.
As such, sending the full details onComplete makes the reports in Slack legible.

In an ideal world, this reporter would allow me to dump the full details during onComplete, but unfortunately WDIOReporter does not expose onComplete.
As such, I am extending my onComplete hook to bridge the gap between the reporter and WDIO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant