Mocha client tests for WebExtensions
This example shows two methods of testing a WebExtension:
- Running tests from within the addon
- Running tests from the commandline using Karma
See https://github.com/Standard8/example-webextension for a more complete example of WebExtension test configuration.
To run tests from within the addon:
cd addon npm install
Testing within the Addon
This gives you the possibility to run client tests inside the addon with the mocha UI. If you don't want to use the mocha UI, you can install WebConsole-reporter.
Run with web-ext cli
npm run web-ext (will work with FF dev edition), if you have error with web-ext cli please add path for FF binary file with
When the addon starts, click on the mocha icon in your browser bar to run the tests:
This will test
Testing from the Commandline
This uses Karma to run tests from the commandline. Just type
npm test to test
You can install karma-notification-reporter to display test results in a desktop notification. You'll need to add
--reporters=dots,notification to the
test:debug command line of
package.json to enable it.