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

Ensure console logging works #4

Open
codeclown opened this issue Feb 23, 2018 · 4 comments
Open

Ensure console logging works #4

codeclown opened this issue Feb 23, 2018 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@codeclown
Copy link
Owner

I haven't tested if this reporter overwrites manual console.logs, and if it does, that should be prevented so that it's possible to log stuff from the tests.

@codeclown
Copy link
Owner Author

This needs to be addressed, current dynamic console output gets messed up when anything else logs in-between.

Addressing this could also remove the need for requiring logLevel: 'silent'.

console.log(chalk.yellow('Warning: wdio-slick-reporter output can break when logLevel !== silent'))

@codeclown
Copy link
Owner Author

codeclown commented Mar 5, 2018

The possible solution I have in mind would be to listen to process.stdout and process.stderr manually and also manually print anything they piped through. Could become messy/unreliable, though, but worth a shot.

process.stdout.on('data', ...)

@codeclown
Copy link
Owner Author

Turns out this isn't that straight-forward because the process in which the reporter runs is different than the process in which the tests run. Therefore, it's not possible to listen to stdout/stderr of the tests in the reporter.

I'll leave this issue open, maybe someone has a solution.

@codeclown codeclown added the help wanted Extra attention is needed label Mar 6, 2018
@codeclown
Copy link
Owner Author

codeclown commented Mar 6, 2018

To clarify, the problem is the following.

Instead of always printing more and more lines after the previous output whenever the state of the suite changes (e.g. a test passes -> should now show "1 passed" instead of "0 passed"), this reporter clears N lines in the console and then just prints the lines that changed compared to the last state.

This works perfectly when nothing but this reporter's output is printed to the console, but it breaks whenever something else logs to the console. Example:

Reporter first prints this:

00-01 ./sample-file.js
  0 passed  0 failed  0 pending

  ❯ Sample test (currently running)

Then some random process, or the currently running test, or wdio, etc. prints something:

00-01 ./sample-file.js
  0 passed  0 failed  0 pending

  ❯ Sample test (currently running)
FOOBAR printed from test

Now, the next time the reporter receives an update, it clears N lines based on its internal state, disregarding the outsider FOOBAR-line. In this case the line that changed is line 2, so 3 lines are cleared before printing the changed lines, and this is the broken result:

00-01 ./sample-file.js
  0 passed  0 failed  0 pending
  1 passed  0 failed  0 pending

  ❯ Sample test (currently running)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant