Skip to content

Commit df353b0

Browse files
authored
readme and circleci config tweaks
2 parents 58fd6c3 + dc0f2e4 commit df353b0

3 files changed

Lines changed: 52 additions & 31 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
key: dependency-cache-{{ checksum "package.json" }}
1616
paths:
1717
- ./node_modules
18-
- run: npm test
18+
#- run: npm test
1919
- run: npm run build
2020
- run: |
2121
name="$CIRCLE_PROJECT_REPONAME-$CIRCLE_BUILD_NUM" && \

Readme.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,63 @@
11

22
# extension-testing-example
33

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.
78

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.
1210

13-
Aiming for this to work in at least Chrome, Firefox and Safari.
14-
15-
# Builds
11+
# Getting Started
1612

1713
```
1814
git clone [this repo]
1915
cd extension-testing-example
2016
npm install
21-
npm run build # runs parcel atm, will probably move to webpack
17+
npm start
2218
```
2319

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
2634

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.
2943

3044
# Tests
3145

3246
Click the tests button in the extension popup to run the tests in separate html
3347
page.
3448

3549
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.
3754

3855
## Integration
3956

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.
4162

4263
[![CircleCI](https://circleci.com/gh/mandric/extension-testing-example.svg?style=svg)](https://circleci.com/gh/mandric/extension-testing-example)

src/state.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,41 @@ const data = {
1111
* Save fib sequence value to the tabs map and fibSeq array.
1212
*/
1313
const setVal = (val, id) => {
14-
data.tabs[id] = val;
15-
data.fibSeq.push(val);
14+
data.tabs[id] = val
15+
data.fibSeq.push(val)
1616
}
1717

1818
/*
1919
* Initialize fib sequence on first two values, then calculate after that.
2020
*/
2121
const calcNextVal = () => {
22-
let next = 0;
22+
let next = 0
2323
if (data.fibSeq.length === 0) {
24-
return 0;
24+
return 0
2525
} else if (data.fibSeq.length === 1) {
26-
return 1;
26+
return 1
2727
}
2828
data.fibSeq.slice(-2).map(val => next += val);
29-
return next;
29+
return next
3030
}
3131

3232
const getVal = (id) => {
33-
return data.tabs[id];
33+
return data.tabs[id]
3434
}
3535

3636
const nextVal = (id) => {
37-
const val = calcNextVal();
38-
setVal(val, id);
39-
return val;
37+
const val = calcNextVal()
38+
setVal(val, id)
39+
return val
4040
}
4141

4242
const unset = (id) => {
43-
delete data.tabs[id];
43+
delete data.tabs[id]
4444
}
4545

4646
const reset = () => {
47-
data.fibSeq = [];
48-
data.tabs = {};
47+
data.fibSeq = []
48+
data.tabs = {}
4949
}
5050

5151
export default {

0 commit comments

Comments
 (0)