-
Notifications
You must be signed in to change notification settings - Fork 15
Add automated test suite. #32
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,16 @@ version: 2 | |
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:10-browsers | ||
- image: circleci/python:2.7-node-browsers | ||
steps: | ||
- checkout | ||
- run: | ||
name: Install dependencies | ||
command: | | ||
pipenv install | ||
npm install | ||
pipenv run mozdownload --version latest --destination $HOME/firefox.tar.bz2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason why you chose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's less stateful, as |
||
pipenv run mozinstall --destination $HOME $HOME/firefox.tar.bz2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CircleCI browser images have a ludicrously old version of Firefox (like, 48). Maybe there's more recent versions elsewhere in the image that I didn't look, but this ensures we test using the latest version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edit: this was answered in slack, but I'll leave it here for posterity. Looks like we are downloading and installing the latest Firefox for each run; could we add an "update" step or make our own image? I see that the Shield Studies Addon Template uses "latest-browsers" for their docker image, though I haven't found a similar one that also has Python. Looks like we may also be able to cache the Firefox binary, so we don't have to install/download all the time? Osmose's reply in slack:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We know that the docker image's Firefox version was old, because Marionette outputs the Firefox version to the terminal right (on
|
||
- run: | ||
name: Build extension | ||
command: | | ||
|
@@ -17,9 +20,15 @@ jobs: | |
name: Run linting checks | ||
command: | | ||
npm run lint | ||
- run: | ||
name: Run automated tests | ||
command: | | ||
pipenv run test -- --firefox_bin $HOME/firefox/firefox | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the -- meant to pass the options to the script run by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, |
||
- run: | ||
name: Package extension as XPI | ||
command: | | ||
npm run package | ||
- store_artifacts: | ||
path: web-ext-artifacts | ||
- store_artifacts: | ||
path: gecko.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
web-ext-artifacts | ||
build | ||
gecko.log | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is generated by Firefox during the Marionette run. It has useful info if Firefox fails in some way during the run. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these listed under packages and not dev-packages? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Python is only necessary for development, I figured we could save having to add |
||
click = "*" | ||
marionette-client = "*" | ||
mozdownload = "*" | ||
mozinstall = "*" | ||
|
||
[requires] | ||
python_version = "2.7" | ||
|
||
[scripts] | ||
test = "npm test" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,35 @@ Prerequisites: | |
npm start | ||
``` | ||
|
||
## NPM Scripts | ||
## Running Tests | ||
|
||
Automated tests are run in a Firefox browser instance using [Marionette][]. We use the Python client for Marionette since there is no up-to-date JavaScript client. | ||
|
||
To set up your environment for running the tests, you must have: | ||
|
||
- A Firefox binary. On MacOS, this can be found within the `.app` folder at `Firefox.app/Contents/MacOS/firefox`. | ||
- Python 2.7 | ||
- [Pipenv][] | ||
|
||
With these installed, you can set up the test suite: | ||
|
||
1. Install Python dependencies: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I needed to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "Prerequisites" section above lists Pipenv as required, and links to the Pipenv website with instructions on how to download. I figured that should be enough to indicate that you need Pipenv installed. |
||
```sh | ||
pipenv install | ||
``` | ||
2. Save the path to your Firefox binary with `npm`: | ||
|
||
```sh | ||
npm config set webext-commerce:firefox_bin <PATH_TO_FIREFOX_BINARY> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might add an example path,since on Mac, it's a pain to find the path to Firefox: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is called out earlier in the README. |
||
``` | ||
|
||
After this, you can run `pipenv run test` to run the automated test suite. | ||
|
||
[Marionette]: https://firefox-source-docs.mozilla.org/testing/marionette/marionette/index.html | ||
[Pipenv]: https://docs.pipenv.org/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL: You can make inline links in this way. |
||
|
||
## Scripts | ||
|
||
| Command | Description | | ||
| --- | --- | | ||
|
@@ -39,6 +67,7 @@ Prerequisites: | |
| `npm run build` | Compile source files with Webpack | | ||
| `npm run watch` | Watch for changes and rebuild | | ||
| `npm run package` | Package the extension into an XPI file | | ||
| `pipenv run test` | Run test suite (See "Running Tests" for setup) | | ||
|
||
## License | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.7? 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blame mozbase and friends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment recommends using Geckodriver or similar (at least for non-Mozilla projects). Why wouldn't we want to do that here? (granted this IS a Mozilla project).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Geckodriver translates the Webdriver protocol into Marionette commands. While Webdriver does include methods for executing JS in the browser, it does not have support for switching to a chrome context and executing privileged code. Since that is one of the benefits of Marionette/Firefox based testing (testing privileged chrome code), we don't want to use Geckodriver since we'd lose that ability.