|
1 | 1 |
|
2 | 2 | # extension-testing-example |
3 | 3 |
|
4 | | -Browser extension example using ES Modules and browser testing with Mocha, Chai |
5 | | -and Sinon. Specifically testing in the browser to exercise the browser APIs |
6 | | -available to extensions. |
| 4 | +Browser extension example using ES Modules and browser testing with Mocha, |
| 5 | +Chai, Sinon and Parcel for bundling. Specifically testing in the browser to |
| 6 | +exercise the browser APIs available to extensions where possible. |
| 7 | +webextension-polyfill is used to standardize the `browser` API. |
7 | 8 |
|
8 | | -Test browser APIs directly where possible and mock with Sinon otherwise. |
9 | | -Sinon-chrome is available to mock chrome but ideally it would mock Firefox too. |
10 | | -webextension-polyfill is used to standardize the `browser` API but have not |
11 | | -tried mocking that yet. |
| 9 | +Aiming for this to work in Chrome, Firefox and Safari. |
12 | 10 |
|
13 | | -Aiming for this to work in at least Chrome, Firefox and Safari. |
14 | | - |
15 | | -# Builds |
| 11 | +# Getting Started |
16 | 12 |
|
17 | 13 | ``` |
18 | 14 | git clone [this repo] |
19 | 15 | cd extension-testing-example |
20 | 16 | npm install |
21 | | -npm run build # runs parcel atm, will probably move to webpack |
| 17 | +npm start |
22 | 18 | ``` |
23 | 19 |
|
24 | | -Then you should be able to load the `dist/` directory into your browser as an |
25 | | -extension and see Fibonacci greatness. |
| 20 | +This should get you started developing, it will create a `dist/` directory that |
| 21 | +you can load into your browser as an extension if you turn on extensions |
| 22 | +developer mode. |
| 23 | + |
| 24 | +Parcel will also watch the source file and rebuild automatically. |
| 25 | + |
| 26 | +Then you should be able to load the `dist/` directory into your browser and see |
| 27 | +Fibonacci greatness. |
| 28 | + |
| 29 | +See the this [Getting Started |
| 30 | +Tutorial](https://developers.chrome.com/extensions/getstarted) for more |
| 31 | +information about developing extensions. |
| 32 | + |
| 33 | +# Builds |
26 | 34 |
|
27 | | -There is currently only one build but in the future only the debug build would |
28 | | -include the tests so anyone can rum them after installation. |
| 35 | +Production/minimized build: |
| 36 | + |
| 37 | +``` |
| 38 | +npm run build # runs parcel build |
| 39 | +``` |
| 40 | + |
| 41 | +There is currently only one build target but in the future only the debug/dev |
| 42 | +build would include the tests so anyone can run them after installation. |
29 | 43 |
|
30 | 44 | # Tests |
31 | 45 |
|
32 | 46 | Click the tests button in the extension popup to run the tests in separate html |
33 | 47 | page. |
34 | 48 |
|
35 | 49 | You can also load the test runner using a web server rather than extension |
36 | | -protocol with `npm run server` and `http://127.0.0.1:8080/test.html`. |
| 50 | +protocol with `npm run server` and `http://127.0.0.1:8080/test/index.html`. |
| 51 | + |
| 52 | +But you can't make any calls to `browser` unless you mock it because it's not |
| 53 | +defined, so some tests will fail. |
37 | 54 |
|
38 | 55 | ## Integration |
39 | 56 |
|
40 | | -Integration tests or e2e yet to be introduced, plan is to use webdriverio. |
| 57 | +Integration tests or e2e is yet to really be introduced, plan is to use |
| 58 | +webdriverio. I'm open to suggestions. |
| 59 | + |
| 60 | +Build artifacts (zip file of dist/) are being saved on CirlceCI but you might |
| 61 | +have to be logged into see them. I will add them to the release page. |
41 | 62 |
|
42 | 63 | [](https://circleci.com/gh/mandric/extension-testing-example) |
0 commit comments