webdriverio-community / wdio-html-reporter

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

HTML fails to generate if event values are objects #105

Open gpaciga opened 1 year ago

gpaciga commented 1 year ago

We have run into cases of trying to log a JavaScript object, without stringifying it. The master json file seems to be generated fine, but the html file is not generated. For example, when logging:

"foobar string"

and

{foobar: object}

the events part of the JSON for the test looks like:

  "events": [
    {
      "type": "log",
      "value": "foobar string"
    },
    {
      "type": "log",
      "value": {
        "foobar": "object"
      }
    }
  ],

so my presumption is that this causes something to go wrong when writing the HTML, but not the JSON.

We are using process.emit("test:log", message) to add to the log, as one step in a custom logging method that does some other things at the same time (console log, allure steps, etc). If there is a more proper way to log things like this that would bypass this issue, I'd be happy to change our implementation. I would just JSON.stringify() everything but I don't want to lose nuance for things that aren't JSON (like NaN, Infinity, etc).

At a minimum, something to surface the error to the user would be nice rather than failing silently.