webdriverio-community / wdio-vscode-service

A service to test VSCode extensions from end to end using WebdriverIO

Home Page:https://webdriverio-community.github.io/wdio-vscode-service/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to use a singleton across all tests? Or is it possible to run the test suites sequentially?

jeffb-sfdc opened this issue · comments

Our extension relies on a dependency, and we need to manage when and how the dependency runs. When our test suites run, they run in parallel and when we run this dependency, we've found that it needs to run sequentially, just one at a time, and this conflicts with our test suites which are running in parallel.

To overcome this, I tried creating a singleton to manage the resource, but I've since found out that each test suite (eg a.e2e.ts, b.e2e.ts, c.e2e.ts, etc...) runs in its own (siloed) memory space.

So when a.e2e.ts runs, Singleton.instance is null and an instance of Singleton() is created (which is expected),
and when b.2e.ts runs, Singleton.instance is ALSO null and a new instance of Singleton() is created (which is not expected),
and when c.2e.ts runs, Singleton.instance is ALSO null...
etc...

I have two questions:

  1. Is it possible to have a singleton be accessible to the various test suites?
  2. When our test suites run, they run at the same time and in parallel. Is it possible to configure a project, so that the test suites run sequentially and only run one test suite at a time? I think if we were able to run the tests suites in series instead of parallel, that would negate the need for us to manage this resource and would negate the need for a singleton.

Thanks,

Jeff

  1. Is it possible to have a singleton be accessible to the various test suites?

Yes , you can write a custom service that launches a Node.js process running that singleton and allowing to communicate to this process via ipc. You can create custom commands to simplify this.

2. Is it possible to configure a project, so that the test suites run sequentially and only run one test suite at a time?

Yes, see https://webdriver.io/docs/organizingsuites#grouping-test-specs-to-run-sequentially