webextension_local_filesystem_links icon indicating copy to clipboard operation
webextension_local_filesystem_links copied to clipboard

Test suites for the web extension (unit & functional tests)

Open AWolf81 opened this issue 5 years ago • 0 comments

We're having some old test cases in test folder but they're not executable as they're pretty old and out-dated. They're not converted to web extensions and still using deprecated jpm SDK syntax.

There is a repo with an unit test example here and it's using Karma as test runner for unit testing. Karma would work but I think we just need jest to run our tests.

I think there is no way to test browser related stuff with web-ext. e.g. the file test/test-launch-local-process.js can be removed as we're using native messaging in the web extension and can't launch a local process.

But we can use other tools like jsdom or webextensions-geckodriver to test web extension specific parts so we can do functional tests (e.g. addon bar icon clicked opens the popup).

The tests we're having are doing tests of some JS files that are not available anymore. So we can remove them.

I paused my work on the project for pretty long as there were other more interesting projects. But I'd like to improve the extension and I'll start with this issue after fixing some more important issues e.g. opening multiple windows or dynamic link scanning are my prios right now.

Todos:

  • [ ] Setup Jest for testing
  • [ ] Use jest-webextension-mock
  • [ ] Setup webextensions-jsdom for functional tests (probably easier than the geckodriver)
  • [ ] Add coverage report
  • [ ] Remove all old test files - not needed anymore
  • [ ] Add new tests to two folders unit and functional
    • [ ] Functional test
      • Native messaging e.g. does it trigger a native message (link click & icon click)
      • Notifications
    • [ ] Unit test
      • Addonbar icon change (mock web extension with jest)
      • Icon adding & link handling in content.js (mock browser.runtime.sendMessage with jest)
  • [ ] Setup CI with CircleCi (optional, but would be nice to have)

Note No integrations tests will be added here as we need to do them in a separate issue. Integration tests will replace the manual link testing e.g. start the webserver in test/webserver and test each link of the server to see if the local file link is correctly opening the link. Automating this manual step would be great e.g. by using cypress.io but that's too much for this issue.

Resources

AWolf81 avatar Aug 06 '19 23:08 AWolf81