Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Have displayName appear in test logs #183

Open
tpronk opened this issue Dec 2, 2020 · 3 comments
Open

Have displayName appear in test logs #183

tpronk opened this issue Dec 2, 2020 · 3 comments

Comments

@tpronk
Copy link

tpronk commented Dec 2, 2020

Hi!

Context
I'm using BrowserStack both for e2e testing and unit testing. I'd like use a common naming scheme for identifying platforms in the logs of both e2e and unit tests. To achieve this on the karma side, I'm setting the displayName property of elements in customLaunchers in the karma configuration (see this page for reference). I'm logging the test results via karma-json-reporter.

My issue
When I run tests locally, I see the displayName showing up in my logs as the name property of a browser. Below are some config and output snippets as illustration...

// In config
customLaunchers = {
  local_local_chrome_local: {
    base: 'Chrome',
    displayName: 'local_local_chrome_local'
  }
}
// In output
{
  "browsers": {
    "40995879": {
      "id": "40995879",
      "fullName": "local_local_chrome_local",
      "name": "local_local_chrome_local",

When I run tests via the karma-browserstack-launcher, I don't get displayName in my logs. Below another config and output snippet to illustrate what I get instead.

// In config
customLaunchers = {
  'android_11.0_Google Pixel 4_android': {
    os: 'android',
    os_version: '11.0',
    browser: 'android',
    device: 'Google Pixel 4',
    browser_version: null,
    real_mobile: true,
    displayName: 'android_11.0_Google Pixel 4_android',
    base: 'BrowserStack'
  }
}

// In output
{
  "browsers": {
    "7827643": {
      "id": "7827643",
      "fullName": "Mozilla/5.0 (Linux; Android 11; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36",
      "name": "Chrome 83.0.4103.106 (Android 11)",

What I tried so far
I tried adjusting your index.js. I found out that I could obtain the displayName as a property of args in this.start and use it to set the name used for the logs on BrowserStack by adjusting this line. I didn't manage to get it into the JSON logs though.

Help :)
Could you give me some pointers in how to get the displayName in the logs?

Thanks! Thomas

@RohanImmanuel
Copy link

@tpronk the "name" capability you are referring to would allow you to set a name for the session on the browserstack dashboard and not in the console logs.

@tpronk
Copy link
Author

tpronk commented Dec 9, 2020

Hey @RohanImmanuel, thanks for your reply!

Yes, the line you and I mention at the bottom of my post can be used to set the name of a session on browserstack. The workaround I'm thinking of will use that and then obtain the name I'd like to have via the browserstack REST API.

If I set the displayName property of a customLauncher, I would have expected to end up in my local logs; if I use the chrome-launcher, for example, displayName ends up as name and fullname in my JSON logs, but not if I use the karma-browserstack-launcher.

@tpronk
Copy link
Author

tpronk commented Dec 9, 2020

I forked the repo and applied my workaround. It's not super-elegant, but it works :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants