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

Allow browser console logs to be retrieved for unit tests #1144

Open
jason0x43 opened this issue Apr 17, 2020 · 1 comment
Open

Allow browser console logs to be retrieved for unit tests #1144

jason0x43 opened this issue Apr 17, 2020 · 1 comment
Labels
effort-medium This may take a couple of days enhancement A new or improved feature priority-low We'll get to this eventually

Comments

@jason0x43
Copy link
Member

Intern should provide an easy way to retrieve logs from remote test sessions.

Requirements

  • Enable or disable log capture per session or globally
  • Optionally capture logs to files (individual session logs should be captured to separate files)

How to retrieve logs

There are a couple ways to implement this. The webdriver API provides a getLogsFor method to retrieve logs. Intern could call that on a session suite when the session is completed to retrieve logs before closing the remote. That method isn't part of the WebDriver spec, though, so it may not be supported in all browsers.

Another option would be for Intern to override the console methods to capture them and send them back to the host. This is probably the better solution because it provides Intern finer control over what is captured and allows logs to be sent back to the host immediately rather than at the end of a test or session.

If the second option is implemented, logs could be emitted as events on the Intern host as they are received.

Configuration

Log capture should be disabled by default, both to minimize the performance impact (there may be a lot of log data) and to prevent intern from breaking any pre-existing modifications to the browser logging system.

Intern should provide config options allowing logging to be enabled on a session-specific basis and allowing logs to be captured to files. The example below is one possible way to handle the config:

{
  // Capture all log levels for all environments
  "captureConsole": true,

  "output": {
    // By default, logs will be captured and emitted as local events. Use a
    // remoteLogs output option to specify a location to save logs to a file.
    "remoteConsole": {
      // Dir to store console messages
      "dir": "logs",
      // If true, show console messages in Intern's output as they are received
      "show": true
    }
  },

  "environments": [
    {
      "browserName": "chrome",
      // Use "intern" capability group for Intern-specific config
      "intern": {
        // only capture info and warn logs
        "captureConsole": ["info", "warn"]
      }
  ]
}
@jason0x43 jason0x43 added enhancement A new or improved feature effort-medium This may take a couple of days priority-low We'll get to this eventually labels Apr 17, 2020
@shashanksjSSJ
Copy link

Hello 😁, I am a beginner to open source contributions, It would ne great if I could solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort-medium This may take a couple of days enhancement A new or improved feature priority-low We'll get to this eventually
Projects
None yet
Development

No branches or pull requests

2 participants