webextension_local_filesystem_links
webextension_local_filesystem_links copied to clipboard
Test suites for the web extension (unit & functional tests)
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
andfunctional
- [ ] 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
(mockbrowser.runtime.sendMessage
with jest)
- [ ] Functional test
- [ ] 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
- https://www.rafspiny.eu/blog/another-painless-conversion-from-jpm-to-webextension
- SO question to unit testing
- Integration tests with jest