webdriverio-community / wdio-html-reporter

Fork of wdio-html-format-reporter
MIT License
18 stars 27 forks source link

Javascript Error in the template report.html #79

Closed netnic0 closed 2 years ago

netnic0 commented 2 years ago

Hi, To Fix: It seems to have an error at the end of the template file of the report.html. I have this error in my broaser console: Uncaught SyntaxError: Unexpected token ')'

```
if () {
        document.querySelectorAll('.suite-header').forEach(item => {
            item.click();
        });
    }
I think it must be 

if (true) { document.querySelectorAll('.suite-header').forEach(item => { item.click(); }); }

rpii commented 2 years ago

The conditional is evaluated by handlebars:

if ({{ ifCollapseTests() }}) { document.querySelectorAll('.test-header').forEach(item => { item.click(); }); } if ({{ ifCollapseSuites() }}) { document.querySelectorAll('.suite-header').forEach(item => { item.click(); }); }

environment.addGlobal('ifCollapseTests', (text:string) => { return reportOptions.collapseTests; });

environment.addGlobal('ifCollapseSuites', (text:string) => { return reportOptions.collapseSuites; });

You should define the two variables in report options. They are defaulted however, so that should not happen.

Rich

On Thu, Jan 20, 2022 at 7:43 AM netnic0 @.***> wrote:

Hi, To Fix: It seems to have an error at the end of the template file of the report.html. I have this error in my broaser console: Uncaught SyntaxError: Unexpected token ')'

if () {
        document.querySelectorAll('.suite-header').forEach(item => {
            item.click();
        });
    }

I think it must be

if (true) { document.querySelectorAll('.suite-header').forEach(item => { item.click(); }); }

— Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/79, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIELNDSC6QI6JAZ6ASF3UXAUPVANCNFSM5MNDCXPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

netnic0 commented 2 years ago

Ok, I understand. Thanks! Nicolas