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

Test results are not sending #1

Open
Khrove opened this issue Mar 12, 2020 · 14 comments
Open

Test results are not sending #1

Khrove opened this issue Mar 12, 2020 · 14 comments

Comments

@Khrove
Copy link

Khrove commented Mar 12, 2020

Node version: 10.16.2
NPM version: 6.13.7
WDIO version: 5.18.4
wdio-slack-service version: 2.0.7

Issue that is occuring:
The only message that is sent to Slack is "Running Tests Report" when I think it's expected that I should receive "Running Tests Report" and then some message containing the test result attachments.

Config:

exports.config = {
 updateJob: false,
    maxInstances: 1,
user: bstack_user,
    key: bstack_key,
    bail: 2,
    capabilities: [{
        'os': browserObj.os,
        'os_version': browserObj.os_version,
        'browserName': process.env.BROWSER,
        'browser_version': browserObj.browser_version,
        build: browserConfig.BUILD,
        'project': browserConfig.PROJECT,
        "sessionName": global.currentTestName,
        'browserstack.local': true,
        'browserstack.debug': true,
        acceptInsecureCerts: true,
        acceptSslCert: true,
        resolution: browserConfig.RESOLUTION
    }],
    reporters: ['spec',
        [HtmlReporter, {
            outputDir: './reports/html-reports',
            filename: 'reports.html',
            reportTitle: 'Test Reports',
            showInBrowser: false,
            useOnAfterCommandForScreenshot: true
        }],
        ['timeline', {
            outputDir: './timeline_reports',
            embedImages: true,
            images: {
                quality: 80,
                resize: false,
                reductionRatio: 2
            },
            screenshotStrategy: 'none'
        }]
    ],
    services: [
        [slack, {
            webhook: process.env.SLACK_WEBHOOK_URL || "...",
        }],
        [TimelineService]
    ],
logLevel: 'warn',
    coloredLogs: true,
    baseUrl: partnerURL,
    waitforTimeout: 20000,
    host: 'hub.browserstack.com',
    framework: 'mocha',
    mochaOpts: {
        ui: 'bdd',
        timeout: '65000',
        compilers: ['@babel/register']
    },
// ... lifecycle hooks
}
@tomasfly
Copy link

Have you found any solution on this? I am getting the same. Just "Running Tests Report

"

@Khrove
Copy link
Author

Khrove commented May 14, 2020

No, I have not found a solution to this yet. Someone will probably have to fork the repo and debug it because it doesn't look like this is being actively maintained.

@tomasfly
Copy link

tomasfly commented May 14, 2020

I realized it seems to notify correctly to the Slack channel when you use framework: 'jasmine' in testrunner configuration. But it doesnt seem to notify when you use 'cucumber'.

@aetjansen
Copy link

I too get only "Running Tests Report" and nothing else in the slack channel. So, it posts to Slack correctly, but not the correct info. I tried with both mocha and jasmine as frameworks used. Using wdio v6.1.11 and current npm package for this slack service.

@adrian-brown
Copy link

Great idea, any chance this is still supported @carmenmitru ? And positioned to work across Jasmine, Mocha and Cucumber frameworks?

@soumyaevan
Copy link

I am also facing the same issue. Any update yet?

@carmenmitru
Copy link
Owner

Hello @soumyaevan, @adrian-brown , @aetjansen @aetjansen , @tomasfly , @Khrove

I updated the npm package. Let me know if now works. I also added the notifyOnlyOnFailure option

@himanshujane3
Copy link

himanshujane3 commented Jul 3, 2020

Hello @carmenmitru
I'm using
"wdio-slack-service": "^2.0.8" and notifyOnlyOnFailure: true,

Observation
Notification is sent even when all the test are passed
And also getting this error
Error in "AfterTest Hook"
Cannot read property 'matcherResult' of undefined

When notifyOnlyOnFailure is set to false - It doesnt send the notification at all.. and i still get the AfterTest Hook error

It seems like flag is set vice versa and there is a bug as well.
It will be great if someone can fix this.. Thanks in advance.

image

Well with some help - I managed to fix it - Could you please review this and push a new version

afterTest(test, context, results) {
this.tests++;
const { error, passed } = results;
if (error && error.matcherResult && error.matcherResult.message()) {
let testError = error.matcherResult
.message()
.replace(
/[\u001b\u009b][[()#;?](?:[0-9]{1,4}(?:;[0-9]{0,4}))?[0-9A-ORZcf-nqry=><]/g,
""
);

  let attach = {
    color: failedColor,
    author_name: test.fullName || `${test.parent} \n  ${test.title}`,
    footer: testError.toString(),
    footer_icon: "https://img.icons8.com/color/48/000000/info--v1.png",
    ts: Date.now(),
  };
  if (!passed) {
    this.failedTests++;
    this.attachments.push(attach);
  }
}

async after() {
if ((this.config.notifyOnlyOnFailure === true && this.failedTests > 0) || this.config.notifyOnlyOnFailure === false) {
this.attachments[0].title += Total tests: ${ this.tests } \n Total passed: ${this.tests - this.failedTests} \n Total failed: ${ this.failedTests };

  await this.webhook.send({
    attachments: this.attachments,
  });
}

}

@mcf1727
Copy link

mcf1727 commented Nov 20, 2020

If I set notifyOnlyOnFailure to true, I can receive reports. But no if it's set as false

@mcf1727
Copy link

mcf1727 commented Nov 20, 2020

with Mocha, even the test failed, in the slack report it's counted as a passed test. I don't know why

@AutomationReddy
Copy link
Contributor

This is fixed in latest version

@xinqilin
Copy link

xinqilin commented Aug 2, 2021

Hi !
Sorry, I have some problem as same as this issue

my dependencies:

"dependencies": {
    "@wdio/cli": "^7.9.0",
    "request": "^2.88.2",
    "request-promise": "^4.2.6",
    "wdio-wiremock-service": "^6.0.6"
  },
  "devDependencies": {
    "@wdio/firefox-profile-service": "^7.8.0",
    "@wdio/local-runner": "^7.8.0",
    "@wdio/mocha-framework": "^7.8.0",
    "@wdio/selenium-standalone-service": "^7.8.0",
    "@wdio/spec-reporter": "^7.8.0",
    "chromedriver": "^91.0.1",
    "wdio-chromedriver-service": "^7.2.0",
    "wdio-slack-service": "^2.0.9"
  },

in my wdio.conf.js setting

            slack, {
                .....
                notifyOnlyOnFailure: true,  // Send notification only on test failure
               .......
            }

and my test report in console
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:09

and there is nothing events push to my slack channel,

Is there any tips to help me, please T_T

@xinqilin
Copy link

xinqilin commented Aug 3, 2021

Sorry , I got where the problem is
in the index.js file
afterTest() method
the line

let testError = results.error.matcherResult.message().replace(/[\u001b\u009b][-[+()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");

result.error.matcherResult always undefined , so .message() is not fuctioning

@DiMavrodiev
Copy link

Hi everyone,

I have been having the same problem as the people above. I have "wdio-slack-service": "^2.0.9" and I use mocha for test running. I get all PASS tests in my slack channel but none of the failing tests are getting into to channel. Any ideas how can I see the failing tests in slack. notifyOnlyOnFailure: true doesn't help

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