6

I am currently trying to refactor an existing gnome-shell extension's codebase. Part of that is introducing unit tests as it seems rather neglectful to not use tests in 2016.

After some tinkering I managed to setup a working node-phantomjs-qunit pipeline that actually gets me somewhere.

However, shell extensions use a custom imports-mechanic as well as some amendments to build in classes (ex: String.format via GJS) that make it impossible to actually test those files in a isolated environment, that is: not within the shell.

So my question is: Is it really true that it is impossible to write unit tests for shell extensions?

Elbenfreund
  • 296
  • 1
  • 3
  • 12
  • Not totally impossible to do but definitely not worth the effort. The small core group of GNOME Shell developers keep changing the internal APIs which means in practice, one often has to rework an extension whenever a new version of the GNOME Shell is released. – fpmurphy Aug 21 '16 at 17:05
  • 1
    @fpmurphy1 thanks for the feedback. I'm well aware of the rapid API changes, but still I think having some basic coverage would still be preferable. If only to get an early warning if things break. – Elbenfreund Aug 21 '16 at 22:49

1 Answers1

1

I've done some work with unit tests with gnome shell extensions, take a look at this extension for a complete example:

https://github.com/emerinohdz/power-alt-tab

I've used webpack with babel (optional) and GJS. It is even built using Travis CI.

I've included a dumb polyfill for the GS parts I needed, and provided an alternative to handle modules, using ES6 imports instead of the default GS imports mechanism. No integration tests are possible right now, only unit tests, but at least you have control of most of your codebase.

emerino
  • 1,100
  • 11
  • 17
  • That doesn't even install Gnome-Shell, much less run any integration tests against it... – Cerin Mar 18 '19 at 17:55
  • The OP asked for unit tests, and that is unit testing the extension (there's even a comment I placed on the answer saying integration tests are not possible), if you are looking for integration tests go for it and let us know how it goes! – emerino Mar 19 '19 at 18:23