webdriverio-community / wdio-video-reporter

Reporter for WebdriverIO that makes videos of failed tests and has optional allure integration

Home Page:https://webdriver.io/docs/wdio-video-reporter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wdio-video-reporter not working with multiremote

pedrofig-td opened this issue · comments

Describe the bug
An exception is thrown when trying to use wdio-video-reporter with multi-remote.

Log

$ npm run localTests

> my-project@1.0.0 localTests
> SELENIUM_SERVER=4.0.0 CHROMEDRIVER=95.0.4638.69 wdio wdio.conf.local.js


Execution of 1 workers started at 2021-11-12T14:46:47.174Z

2021-11-12T14:46:47.175Z DEBUG @wdio/utils:initialiseServices: initialise service "shared-store" as NPM package
2021-11-12T14:46:47.244Z DEBUG @wdio/utils:initialiseServices: initialise service "selenium-standalone" as NPM package
2021-11-12T14:46:47.273Z INFO @wdio/cli:launcher: Run onPrepare hook
2021-11-12T14:46:47.286Z INFO @wdio/shared-store-service: Started shared server on port 63187
2021-11-12T14:46:49.535Z DEBUG @wdio/cli:utils: Finished to run "onPrepare" hook in 2262ms
2021-11-12T14:46:49.538Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2021-11-12T14:46:49.538Z DEBUG @wdio/cli:utils: Finished to run "onWorkerStart" hook in 0ms
2021-11-12T14:46:49.539Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdio.conf.local.js
[0-0] 2021-11-12T14:46:49.610Z WARN @wdio/utils:shim: You are running tests with @wdio/sync which will be discontinued starting Node.js v16.Read more on https://github.com/webdriverio/webdriverio/discussions/6702
[0-0] 2021-11-12T14:46:49.968Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2021-11-12T14:46:49.970Z DEBUG @wdio/config:ConfigParser: No compiler found, continue without compiling files
[0-0] 2021-11-12T14:46:50.077Z DEBUG @wdio/local-runner:utils: init multiremote session
[0-0] 2021-11-12T14:46:50.081Z DEBUG @wdio/utils:initialiseServices: initialise service "shared-store" as NPM package
[0-0] 2021-11-12T14:46:50.122Z DEBUG @wdio/utils:initialiseServices: initialise service "selenium-standalone" as NPM package
[0-0] 2021-11-12T14:46:50.141Z DEBUG @wdio/sync: Finished to run "beforeSession" hook in 1ms
[0-0] RUNNING in MultiRemote - /tests/specs/test.spec.js
[0-0] 2021-11-12T14:46:50.295Z DEBUG @wdio/local-runner:utils: init multiremote session
[0-0] 2021-11-12T14:46:50.297Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2021-11-12T14:46:50.300Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session
[0-0] 2021-11-12T14:46:50.300Z INFO webdriver: DATA {
[0-0]   capabilities: {
[0-0]     alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': [Object] },
[0-0]     firstMatch: [ {} ]
[0-0]   },
[0-0]   desiredCapabilities: {
[0-0]     browserName: 'chrome',
[0-0]     'goog:chromeOptions': { args: [Array] }
[0-0]   }
[0-0] }
[0-0] 2021-11-12T14:46:50.305Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2021-11-12T14:46:50.305Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session
[0-0] 2021-11-12T14:46:50.306Z INFO webdriver: DATA {
[0-0]   capabilities: {
[0-0]     alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': [Object] },
[0-0]     firstMatch: [ {} ]
[0-0]   },
[0-0]   desiredCapabilities: {
[0-0]     browserName: 'chrome',
[0-0]     'goog:chromeOptions': { args: [Array] }
[0-0]   }
[0-0] }
[0-0] 2021-11-12T14:46:56.309Z DEBUG @wdio/sync: Finished to run "before" hook in 0ms
[0-0] 2021-11-12T14:46:56.313Z ERROR @wdio/local-runner: Failed launching test session: TypeError: Cannot read property 'filter' of undefined
[0-0]     at Video.onRunnerStart (/Users/user/work/git/my-project/regression-tests/node_modules/wdio-video-reporter/dist/wdio-video-reporter.js:483:51)
[0-0]     at Video.<anonymous> (/Users/user/work/git/my-project/regression-tests/node_modules/@wdio/reporter/build/index.js:59:18)
[0-0]     at Video.emit (events.js:314:20)
[0-0]     at Video.EventEmitter.emit (domain.js:483:12)
[0-0]     at /Users/user/work/git/my-project/regression-tests/node_modules/@wdio/runner/build/reporter.js:36:56
[0-0]     at Array.forEach (<anonymous>)
[0-0]     at BaseReporter.emit (/Users/user/work/git/my-project/regression-tests/node_modules/@wdio/runner/build/reporter.js:36:25)
[0-0]     at Runner.run (/Users/user/work/git/my-project/regression-tests/node_modules/@wdio/runner/build/index.js:113:24)
[0-0]     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-11-12T14:46:56.340Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in MultiRemote - /tests/specs/test.spec.js
2021-11-12T14:46:56.342Z INFO @wdio/cli:launcher: Run onComplete hook
2021-11-12T14:46:56.343Z INFO @wdio/selenium-standalone-service: shutting down all browsers
2021-11-12T14:46:56.348Z DEBUG @wdio/cli:utils: Finished to run "onComplete" hook in 5ms

Spec Files:	 0 passed, 1 failed, 1 total (100% completed) in 00:00:09

2021-11-12T14:46:56.349Z INFO @wdio/local-runner: Shutting down spawned worker
2021-11-12T14:46:56.600Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2021-11-12T14:46:56.600Z INFO @wdio/local-runner: shutting down

To Reproduce

  • Install wdio-video-reporter
  • Configure multiremote in wdio.conf.js. Example:

capabilities: {
        phoneAtlasA: {
            capabilities: {
                browserName: 'chrome',
                'goog:chromeOptions': {
                    args: ['disable-infobars', 'window-size=1920,1080']
                }
            }
        },
        phoneAtlasB: {
            capabilities: {
                browserName: 'chrome',
                'goog:chromeOptions': {
                    args: ['disable-infobars', 'window-size=1920,1080']
                }
            }
        }
    },
  • Run any spec

Expected behavior
The spec should execute, and a video should be recorded.

Environment (please complete the following information):

  • wdio-video-reporter version: 3.1.3
  • WebdriverIO version: 7.14.1
  • Mode: WDIO Testrunner
  • If WDIO Testrunner, running sync/async: sync
  • Node.js version: v12.20.0
  • NPM version: 8.1.0
  • Browser name and version: Chrome 95.0.4638.69
  • Platform name and version: macOS Big Sur Version 11.6

Desktop (please complete the following information):

  • OS: macOS Big Sur Version 11.6
  • Browser Chrome
  • Version 95.0.4638.69

Additional context
NA

Thanks for reporting @pedrofig-td! Any contributions are much appreciated, cheers!

Hi @christian-bromann I got some fix/solution for this issue and want to contribute to fix it. The solution works in below cases:

  1. When wdio run in non multi remote mode
    capabilities: [{
    browserName: 'chrome',
    }],
  2. When wdio run in multi remote mode with one browser (browser capability is given custom name)
    capabilities: {
    Mybrowser1 : {
    capabilities: {
    browserName: 'chrome',
    },
    }
    }
  3. When wdio run in multi remote mode with two browser - Here we get video from one browser only. But Tests do not stop and runs as they should. Now how to get two videos in one test that can be a future enhancement, imo
    capabilities: {
    Mybrowser1 : {
    capabilities: {
    browserName: 'chrome',
    },
    },
    Mybrowser2 : {
    capabilities: {
    browserName: 'chrome',
    },
    }
    }

Both 2 and 3 are use cases for my application, As i am using multi remote mode with some custom initiation.

However there are two issues for me to create PR for this fix

  1. To build the soln it needs test coverage of 98 % which is quite high. It needs
    Jest: "global" coverage threshold for statements (98%) not met: 70.18%
    Jest: "global" coverage threshold for branches (98%) not met: 73%
    Jest: "global" coverage threshold for lines (98%) not met: 71.08%
    Jest: "global" coverage threshold for functions (74%) not met: 56.82%

Here the interesting thing is the file which is lacking test coverage is helpers.js and my fix have not even touched helper.js so I am wondering how this lack of test coverage went to main branch at the first place?
I can try to add some tests if its a strict requirement to have that threshold in unit test coverage. But that is delaying the fix for both me and the community.

  1. The wdio demo tests given in this repository does not work without even my fix so how should I prove that my fix for this issue works for wdio tests?

For the sake of my verification i have build the solution with my fix by reducing test coverage threshold and then I copy pasted the generated video reporter in wdio-demo sample tests (sample generated test for herokuapp which we get when we install wdio) and the soln works perfectly.

I am wondering how this lack of test coverage went to main branch at the first place?

Please raise a PR so I can check what is causing this. For us it is just important that changes are accompanied with unit tests. You are not required to increase the coverage.

I can try to add some tests if its a strict requirement to have that threshold in unit test coverage. But that is delaying the fix for both me and the community.

Our definition of done includes proper test coverage. We can't ship it to the community without that.

2. The wdio demo tests given in this repository does not work without even my fix so how should I prove that my fix for this issue works for wdio tests?

I am not sure what kind of issues you are experiencing. Please raise a separate issue if you can't get the project build.

Hi Again @christian-bromann , Please look at the PR. Please let me know if the fix is ok or suggest where we can improve it.

I will try to increase unit test coverage asap for me :)

Cool, thanks! Let's continue convo in #72