5
4 Comments

What automated testing strategies do you use?

Hey all, just wondering what automated testing strategies you use, if any, with your extensions.

on October 5, 2020
  1. 1

    Our automated testing infrastructure for PixieBrix is definitely still a work in progress, but here's some notes:

    • Using Typescript has been a big win. Looking back, I wish we would hav enabled strictNullChecks, as those are the only type errors we get
    • We use Jest for unit tests. There's some mocks we use (e.g., jest-webextension-mock, fake-indexeddb). To ease testing, you may want to separate your extension UX from the code that interacts with other pages
    • As @rfitz mentioned, use a tool like Rollbar for error tracking. There's just a bit of configuration to make sure it handles chrome-extension URLs correctly

    You can checkout the pixiebrix-extension repository on GitHub for how we set things up.

    We'll be looking to set up Puppeteer soon

  2. 1

    @rfitz hoping you have some ideas / suggestions here.

    1. 2

      I've typically just done a combination of Puppeteer, regular React component testing, and unit tests (Jest) and that will normally give me enough confidence in my extension.

      The React component testing and unit tests are done like you would in any other app, but the Puppeteer requires a little bit of extra setup (you need some additional flags like --disable-extensions-except for it to run). After that, you can load up your extension headless via Puppeteer and simulate clicks, scroll, etc similar to Selenium.

      Another thing that goes a long way is setting up proper error tracking so you can be responsive to anything that may come up. Much like everything else in extension development, it's a bit trickier to setup than in a normal app, but overall not much work. I wrote about that a bit here.

      Hope that helps a bit!

  3. 1

    I'd be interested to know as well.

    Addons are generally a pain to automate in general, tho testing of various parts of the addons might be a much easier proposition. Previously, the least that I've done was to separate the UI (popup and full addon pages) and build them with React. This way I could at least test the functionality of the front end.

    Before that, I've used selenium to auto run and addon over about 1000 sites and then compare the output of what the addon is supposed to have with what I know is supposed to happen. This was a painful setup in just about every piece from setting up browser, to running this somewhere in a cloud, to updating the test, etc etc.