So, my question is generally about some debugging and troubleshooting for people who don't really understand programming at all. Is it possible to create a method like:
public foo(method){
try(){
method();
}
catch(error){
console.log(method().name 'caused an error');
throw Error;
}
is it generally okay to do something like that, yes, I know that errors are shown very good even without something similar but if, for example I'm doing testing for a client who wants to know about everything and see what's exactly goes wrong. I'd like to let him know about problems as much as I can, I already have allure reporter on my project but it is not enough
CodePudding user response:
Probably it is. But there are so many good ways to use logger to use allure report with step description for every single method that you run.
So people will see every action which is called in human-readable form. They will have a stack trace with screenshot and video, it can't get better than that.
To use allure in playwright.config file use
reporter: [
["allure-playwright"],
["list"]
],
also, list
"allure-commandline": "^2.13.0",
"allure-playwright": "^2.0.0-beta.14",
in package.json
You can cal every method like this
await test.step('Exatc action in method described in human readable language e.g. Click Send Button', async () => {
// ...your method
});
Also, there is a test error built-in playwright, so you do not need to build your own. See section:
testStep.error
type: <TestError>
on: https://playwright.dev/docs/api/class-teststep#test-step-error
For opening allure use:
"open-allure": "allure generate ./target/allure-results -c ./allure-report && allure open",
And one more thing. Playwright has the best debug mode on market, it shows your code and every action in browser see: https://playwright.dev/docs/inspector