Closed ajaygoutham1995 closed 1 year ago
Duplicate of #15258.
You should implement a custom reporter that would send the mail. Reporters always run at the end, so it will not miss anything.
have you seen this https://github.com/cenfun/monocart-reporter#send-email
Hi Guys,
Help Required..!
Am able to send an email report, but how can i call the report capabilities and reportData on onEnd hook, any reference would be more helpful.
Note : currently am using onEnd hook in playwrightconfig.ts due to this i could not able to pass a currently running test name as report name any alternative for this.
Regards, AjayGowtam
K,Ajay goutham Ph: 8297621226
On Wed, Apr 19, 2023 at 7:49 PM Dmitry Gozman @.***> wrote:
Duplicate of #15258 https://github.com/microsoft/playwright/issues/15258 .
You should implement a custom reporter https://playwright.dev/docs/api/class-reporter that would send the mail. Reporters always run at the end, so it will not miss anything.
— Reply to this email directly, view it on GitHub https://github.com/microsoft/playwright/issues/22486#issuecomment-1514821710, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALR4GDUBYJECYQ67MHFAUJDXB7YAXANCNFSM6AAAAAAXEA4GZI . You are receiving this because you authored the thread.Message ID: @.***>
have you seen this https://github.com/cenfun/monocart-reporter#send-email
yes i have already implemented, but could not able to pass the currently running test name as report name
what do you mean "the currently running test name"? the onEnd hook will be called after all tests are done.
On Mon, 15 May 2023 at 4:04 PM, cenfun @.***> wrote:
what do you mean "the currently running test name"? the onEnd hook will be called after all tests are done.
— Reply to this email directly, view it on GitHub https://github.com/microsoft/playwright/issues/22486#issuecomment-1547608045, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALR4GDVJO3JHKZI7H2FPN4LXGIBDJANCNFSM6AAAAAAXEA4GZI . You are receiving this because you authored the thread.Message ID: @.***>
Am trying to pass the executed file name as report file name.html
Example if i execute somke.test.ts and i would want to pass that test file name as report name like smoketest.html
any Idea how we can achieve it would be more helpful. --
K,Ajay goutham Ph: 8297621226
the report file name could be configured in playwright.config.js
// playwright.config.js
module.exports = {
reporter: [
['list'],
['monocart-reporter', {
name: "My Test Report Title",
outputFile: './your-test-report-dir/your-test-report-filename.html'
}]
]
};
>
the report file name could be configured in playwright.config.js
// playwright.config.js module.exports = { reporter: [ ['list'], ['monocart-reporter', { name: "My Test Report Title", outputFile: './your-test-report-dir/your-test-report-filename.html' }] ] };
outputFile: './your-test-report-dir/{how to pass this name dynamically ?}.html'
How to pass the report name dynamically ?
I don't think we can pass test file name as report name in playwrightconfig.ts, do you have any idea ?
below is my code :
['monocart-reporter', { name :
${test.title}`, // am getting this value as undefined in report
outputFile: "./testReport/monocart.html",
onEnd: async (reportData, capability) => {
const sendEmail = require('./emailConfig.ts');
await sendEmail(reportData, capability);
}
}],`
do you want to pass the report filename after test done? or at the beginning? here your are:
// playwright.config.js
// attachments outputDir and report outputFile used same folder
const date = new Date().toISOString().slice(0, 10); //2022-10-10
const outputDir = `./test-results/${date}`;
module.exports = {
outputDir: outputDir,
reporter: [
['monocart-reporter', {
name: `My Test Report ${date}`,
outputFile: `${outputDir}/index.html`
}]
]
};
do you want to pass the report filename after test done?
yes, Example imagine there is a file called smoke.test.ts and after execution of this file, Now I would want my report name also as similar to test file that is smoke.test.html
I hope now you got the question.
And now tell me how we can achieve
yes, got your question. but we can NOT pass the dynamic name in the current version (will think about how to implement it) anyway there is a way you can try (rename the report filename dynamically)
module.exports = {
outputDir: outputDir,
reporter: [
['monocart-reporter', {
onEnd: async (reportData, capability) => {
// rename report filename
const fs = require('fs');
const path = require('path');
fs.renameSync(
path.resolve(reportData.htmlPath),
path.resolve(reportData.outputDir, 'new-filename.html')
);
}
}]
]
};
yes, got your question. but we can NOT pass the dynamic name in the current version (will think about how to implement it) anyway there is a way you can try (rename the report filename dynamically)
module.exports = { outputDir: outputDir, reporter: [ ['monocart-reporter', { onEnd: async (reportData, capability) => { // rename report filename const fs = require('fs'); const path = require('path'); fs.renameSync( path.resolve(reportData.htmlPath), path.resolve(reportData.outputDir, 'new-filename.html') ); } }] ] };
Got it, Thank you so much...!
Hello I tried implementing above but I am getting below error
Error: connect ETIMEDOUT
I also tried adding host and port
host: 'smtp-mail.outlook.com',
port: 587,
but still getting timeout error Can someone please help Thanks in advance
@afreen07 try Hotmail service directly exmaple: https://github.com/cenfun/playwright-reporter-integrations/blob/main/send-email/send-email.js#L11 see details: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json#L101-L106
@afreen07 try Hotmail service directly exmaple: https://github.com/cenfun/playwright-reporter-integrations/blob/main/send-email/send-email.js#L11 see details: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json#L101-L106
Thanks for your quick response #cenfun but using Hotmail directly dint work It was also giving timeout error then I tried adding host and port which also dint work
I hope you are using office365 username along with the profile password then only it will work.
K,Ajay goutham Ph: 8297621226
On Thu, 30 May 2024 at 12:26 PM, afreen07 @.***> wrote:
@afreen07 https://github.com/afreen07 try Hotmail service directly exmaple: https://github.com/cenfun/playwright-reporter-integrations/blob/main/send-email/send-email.js#L11 see details: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json#L101-L106
Thanks for your quick response #cenfun but using Hotmail directly dint work It was also giving timeout error then I tried adding host and port which also dint work
— Reply to this email directly, view it on GitHub https://github.com/microsoft/playwright/issues/22486#issuecomment-2138811232, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALR4GDW6QYC3MUNC3POEBQLZE3ETNAVCNFSM6AAAAAAXEA4GZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZYHAYTCMRTGI . You are receiving this because you authored the thread.Message ID: @.***>
please help add Mail plugin to send the email to different services like gmail outlook etc..
Usecase and Observation : as per the observation currently we are using nodemailer to send the reports generated by playwright and that is also some times not working due to asynchronous nature and some times it's picking n-1 report which is already exist so it would be very helpful if we have a mailing functionality to send an email
Issue with the node mailer : nodemailer works along with the hooks but the reports are generating after completion of context, in this case we could not able to sync hold to gather