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

Make WCT reuse browser instance across test runs #796

Closed
nicojs opened this issue Nov 26, 2018 · 2 comments
Closed

Make WCT reuse browser instance across test runs #796

nicojs opened this issue Nov 26, 2018 · 2 comments
Labels

Comments

@nicojs
Copy link

nicojs commented Nov 26, 2018

We're using the public api of WCT for the stryker-wct-runner (a plugin to use wct in Stryker): stryker-mutator/stryker-js#1252. Namely the steps file.

We're using it to initialize the test runner and then make a lot of test runs in quick succession. Pseudocode:

await steps.setupOverrides(this.context);
await steps.loadPlugins(this.context);
await steps.configure(this.context);
await steps.prepare(this.context);

while(someCondition){
   // Write changes to the input files
   await steps.runTests(this.context);
   // Read test results
}

This works functionally. However, each time we call runTests a new browser instance is started, which executes the tests and closes the browser. If we enable persistent, the runTests promise never resolves and the "run-end" event is never triggered.

Is there some other way to make WCT reuse the same browser instance for across multiple test runs? Maybe refresh the browser (this is the way Karma works), instead of closing it and opening a new one? I feel comfortable that reusing the same browser instance between runs would at least double the speed of mutation testing web components.

@nicojs nicojs changed the title Make WCT reuse browser instances across test runs Make WCT reuse browser instance across test runs Nov 27, 2018
nicojs added a commit to stryker-mutator/stryker-js that referenced this issue Dec 11, 2018
Add the `stryker-wct-runner` package. A plugin to use [web-component-tester](https://github.com/Polymer/tools/tree/master/packages/web-component-tester) with Stryker. It allows WCT to use the default `wct.conf.json` configuration, or you can configure it with the `wct` property in your stryker.conf.js file. For example: 

```js
// Full example
wct: {
    configFile: 'alternative/wct/configuration.json',
    verbose: true,
    npm: true,
    plugins: {
        local: {
            browsers: ["chrome"],
            skipSeleniumInstall: true,
            browserOptions: {
                chrome: ["window-size=1920,1080", "headless", "disable-gpu"],
                firefox: ["--headless"]
            }
        }
    }
}
```

For more information, see the readme.md.

Some more points:

* `web-component-tester` is a peer dependency. Users are responsible to install a correct version. 
* WCT can be chatty. By default, all log messages are ignored. Setting `wct.verbose` to `true` will forward all wct logging to Stryker's logging system.
* WCT uses Node's `promisify` implementation directly. As such, it will only work from node 8 onward. For that reason, wct integration tests don't run on our node 6 build. 
* The option `persistent: false` is forced as wct option, because `persistent: true` keeps the browser open and Stryker cannot read the test results. See Polymer/tools#796 for more details.
@stale
Copy link

stale bot commented Mar 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 4, 2020
@stale
Copy link

stale bot commented Apr 29, 2022

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

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

No branches or pull requests

1 participant