Allow to run unit tests within the browser
Currently the WebdriverIO testrunner is used to run e2e tests in Node.js. However there are tools like Karma that still have a lot popularity. I don't see a reason why WebdriverIO should not allow to also run unit tests in the browser. Rather than initiating a framework as we do right now, we would would use browserify or other bundlers to create a script that will be executed in a browser window.
Without much investigation my suggestion is to enhance the framework adapter to manage this.
- for Mocha: https://mochajs.org/#running-mocha-in-the-browser
- for Jasmine adapt what https://github.com/jasmine/jasmine-browser does
- for Cucumber adapt what https://github.com/s9tpepper/karma-cucumberjs does
This feature idea was influenced by conversations in https://github.com/sinonjs/fake-timers/issues/380
Would this be in addition to allowing tests to be run in Node.js, or a replacement for that?
@klamping an addition. Most people still want to run WebDriver tests.
Jest is easily the/one of the most popular unit test frameworks, if we will allow unit testing and we exclude Jest then I forsee people wanting it added ^^;
@erwinheitzman It's also the hardest target since it does so much more than just running tests. Tom Sherman has some good insights into how he managed to cram Jest inside of a Karma setup: https://github.com/tom-sherman/blog/blob/master/posts/02-running-jest-tests-in-a-browser.md
The one thing you are not able to do (easily) is ES module mocking in the browser, which Jest otherwise achieves using some Node specific magic. To get that working you would need something like import maps.
This landed with WebdriverIO v8 and the new browser runner: https://webdriver.io/docs/component-testing