18F / 18f-scaffolding

A scaffold/generator to standardize 18F project setup
Other
26 stars 14 forks source link

Scaffolds for adding browser/DOM testing to setup #44

Open msecret opened 7 years ago

msecret commented 7 years ago

In order for developers to run their front end unit tests in an actual browser to leverage all the browser APIs, there should be a scaffold for setting up a browser for testing.

shawnbot commented 7 years ago

Yes! I've had lots of success with webdriver.io, and I particularly like that it works with mocha's test APIs. It would be really awesome if we could find a way to make this (optionally) work with jsdom so that folks don't have to get Selenium working locally just to run the tests. In other words:

msecret commented 7 years ago

I like the idea of allowing either jsdom or selenium. I'd always opt for jsdom first and move to selenium if my code is really complex (which often breaks in jsdom)

shawnbot commented 7 years ago

Hmmm... Now that I think about it, I'm not sure if that level of abstraction is possible. Browser tests usually involve lots of serial async actions over the Selenium protocol, whereas jsdom can do everything synchronously. webdriver.io's v4 upgrade guide explains how you can write synchronous tests that are transformed to async at runtime, but I think that in order to write tests that work in both jsdom and webdriver.io, you'd need to write some sort of jsdom → webdriver.io API adapter.

So maybe jsdom isn't the thing here, but the default is PhantomJS, which is as "modern" as we probably need it to be in terms of native API support and does its own Selenium protocol communication so you don't have to install Selenium server and drivers for local browsers just to run the tests?