Webpack: Replace phantomjs/selenium with electron for testing?

Created on 17 May 2016  路  5Comments  路  Source: vuejs-templates/webpack

Under the covers it uses Electron, which is similar to PhantomJS but faster and more modern.

  • nightmare

Here is part of what the change might look like:

Pros:

  • "Faster and more modern" & under more active development (than phantomjs)
  • No Java environment required (by selenium)

Cons:

Related:


Oops. Just found that selenium part contains both chrome and firefox,
which can't be achieved by electron :sweat:

discussion

Most helpful comment

Selenium is still absolutely necessary, because Electron is only Chromium and we want to run tests in multiple environments. The default runs in Chrome & Firefox but the user can configure it to run in even more browsers.

The phantomjs usage is mostly for headless testing on CI environments. There are two concerns though:

  1. Electron's download size seems to be even heavier. (Phantom 17mb vs Electron 30~40mb)
  2. Electron is not a pure-browser environment, with Node and it's own special globals. This may cause unexpected problems for user code that are solely intended for browser environments.

All 5 comments

Very interesting! I'd never considered this use case for electron. It certainly does seem to have its benefits.

While I do feel some hesitation to switch from _the devil I know_, I think it might be worth the loss of Chrome + Firefox testing. I'm always developing in Chrome already and I can't remember the last time a test failed only in Firefox, honestly. The quirks usually result in things I'm _not_ testing for, like the alignment of an SVG node. I'd be curious to hear others' experiences.

The speed of tests on the other hand, is a pain I definitely have felt on large applications. 馃檪 If I could cut those build times down by half or a third, that'd be... amazing!

Selenium is still absolutely necessary, because Electron is only Chromium and we want to run tests in multiple environments. The default runs in Chrome & Firefox but the user can configure it to run in even more browsers.

The phantomjs usage is mostly for headless testing on CI environments. There are two concerns though:

  1. Electron's download size seems to be even heavier. (Phantom 17mb vs Electron 30~40mb)
  2. Electron is not a pure-browser environment, with Node and it's own special globals. This may cause unexpected problems for user code that are solely intended for browser environments.

So, what about jsdom for unit testing?

@guidobouman jsdom isn't a full browser implementation, so is probably more likely to cause failures for features that do in fact work in real browsers.

It seems that this isn't the right time to move away from phantomjs, due to the concerns @yyx990803 mentioned. It could well be that electron's node environment doesn't really cause problems in practice, but we probably don't want Vue users to be the guinea pigs in this experiment. When there are more examples of large projects using electron to test against, we can revisit this. 馃槂

Was this page helpful?
0 / 5 - 0 ratings