Skip to content

Commit 492f310

Browse files
author
Arthur Evans
committed
Add notes on running unit tests.
1 parent 0dc69df commit 492f310

File tree

1 file changed

+88
-10
lines changed

1 file changed

+88
-10
lines changed

CONTRIBUTING.md

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
There are many ways to contribute to the Polymer project! We welcome and truly appreciate contribution in all forms - issues and pull requests to the [main library](https://github.com/polymer/polymer), issues and pull requests to the [elements the Polymer team maintains](https://github.com/polymerelements), issues and pull requests to one of our many [Polymer-related tools](https://github.com/polymer), and of course we love to hear about any Polymer elements that you build to share with the community!
44

5-
# Logistics
5+
## Logistics
66

7-
## Communicating with the Polymer team
7+
### Communicating with the Polymer team
88

99
Beyond Github, we try to have a variety of different lines of communication open:
1010

@@ -14,7 +14,7 @@ Beyond Github, we try to have a variety of different lines of communication open
1414
* [Mailing list](https://groups.google.com/forum/#!forum/polymer-dev)
1515
* [Slack channel](https://bit.ly/polymerslack)
1616

17-
## The Polymer Repositories
17+
### The Polymer Repositories
1818

1919
Because of the component-based nature of the Polymer project, we tend to have lots of different repositories. Our main repository for the Polymer library itself is at [github.com/Polymer/polymer](https://github.com/polymer/polymer). File any issues or pull requests that have to do with the core library on that repository, and we'll take a look ASAP.
2020

@@ -24,17 +24,17 @@ The GoogleWebComponents element product line is maintained by teams all across G
2424

2525
We also track each element product line overall in "meta-repos", named as `$PRODUCTLINE-elements`. These include [paper-elements](https://github.com/polymerelements/paper-elements), [iron-elements](https://github.com/polymerelements/iron-elements), [gold-elements](https://github.com/polymerelements/gold-elements), and more. Feel free to file issues for element requests on those meta-repos, and the README in each repo tracks a roadmap for the product line.
2626

27-
## Contributor License Agreement
27+
### Contributor License Agreement
2828

2929
You might notice our friendly CLA-bot commenting on a pull request you open if you haven't yet signed our CLA. We use the same CLA for all open-source Google projects, so you only have to sign it once. Once you complete the CLA, all your pull-requests will automatically get the `cla: yes` tag.
3030

3131
If you've already signed a CLA but are still getting bothered by the awfully insistent CLA bot, it's possible we don't have your GitHub username or you're using a different email address. Check the [information on your CLA](https://cla.developers.google.com/clas) or see this help article on [setting the email on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
3232

3333
[Complete the CLA](https://cla.developers.google.com/clas)
3434

35-
# Contributing
35+
## Contributing
3636

37-
## Filing bugs
37+
### Filing bugs
3838

3939
The Polymer team heavily uses (and loves!) Github for all of our software management. We use Github issues to track all bugs and features.
4040

@@ -46,7 +46,7 @@ We love examples for addressing issues - issues with a Plunkr, jsFiddle, or jsBi
4646

4747
Occasionally we'll close issues if they appear stale or are too vague - please don't take this personally! Please feel free to re-open issues we've closed if there's something we've missed and they still need to be addressed.
4848

49-
## Contributing Pull Requests
49+
### Contributing Pull Requests
5050

5151
PR's are even better than issues. We gladly accept community pull requests. In general across the core library and all of the elements, there are a few necessary steps before we can accept a pull request:
5252

@@ -55,20 +55,98 @@ PR's are even better than issues. We gladly accept community pull requests. In g
5555
- Fork the repo you're making the fix on to your own Github account.
5656
- Code!
5757
- Ideally, squash your commits into a single commit with a clear message of what the PR does. If it absolutely makes sense to keep multiple commits, that's OK - or perhaps consider making two separate PR's.
58-
- **Include tests that test the range of behavior that changes with your PR.** If you PR fixes a bug, make sure your tests capture that bug. If your PR adds new behavior, make sure that behavior is fully tested. Every PR *must* include associated tests.
58+
- **Include tests that test the range of behavior that changes with your PR.** If you PR fixes a bug, make sure your tests capture that bug. If your PR adds new behavior, make sure that behavior is fully tested. Every PR *must* include associated tests. (See [Unit tests](#unit-tests) for more.)
5959
- Submit your PR, making sure it references the issue you created.
6060
- If your PR fixes a bug, make sure the issue includes clear steps to reproduce the bug so we can test your fix.
6161

6262
If you've completed all of these steps the core team will do its best to respond to the PR as soon as possible.
6363

64-
### Contributing Code to Elements
64+
#### Contributing Code to Elements
6565

6666
Though the aim of the Polymer library is to allow lots of flexibility and not get in your way, we work to standardize our elements to make them as toolable and easy to maintain as possible.
6767

6868
All elements should follow the [Polymer element style guide](http://polymerelements.github.io/style-guide/), which defines how to specify properties, documentation, and more. It's a great guide to follow when building your own elements as well, for maximum standardization and toolability. For instance, structuring elements following the style guide will ensure that they work with the [`iron-component-page`](https://github.com/polymerelements/iron-component-page) element, an incredibly easy way to turn any raw element directly into a documentation page.
6969

70-
### Contributing Code to the Polymer library
70+
#### Contributing Code to the Polymer library
7171

7272
We follow the most common javascript and HTML style guidelines for how we structure our code - in general, look at the code and you'll know how to contribute! If you'd like a bit more structure, the [Google Javascript Styleguide](https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml) is a good place to start.
7373

7474
Polymer also participates in Google's [Patch Rewards Program](http://www.google.com/about/appsecurity/patch-rewards/), where you can earn cold, hard cash for qualifying security patches to the Polymer library. Visit the [patch rewards page](http://www.google.com/about/appsecurity/patch-rewards/) to find out more.
75+
76+
## Unit tests
77+
78+
All Polymer projects use [`web-component-tester`](https://github.com/Polymer/web-component-tester) for unit tests.
79+
The [`polyserve`](https://github.com/PolymerLabs/polyserve) utility is helpful for running tests in the browser.
80+
81+
For maximum flexibility, install `web-component-tester` and `polyserve` locally:
82+
83+
npm install -g polyserve web-component-tester
84+
85+
### Running the Polymer library unit tests
86+
87+
To run the Polymer library unit tests:
88+
89+
1. Clone the [Polymer repo](https://github.com/polymer/polymer).
90+
91+
2. Install the dependencies:
92+
93+
npm install && bower install
94+
95+
3. Run the tests:
96+
97+
npm test
98+
99+
Or if you have `web-component-tester` installed locally:
100+
101+
wct
102+
103+
You can also run individual test suites:
104+
105+
<code>npm test <i>path/to/suite</i>
106+
107+
Or:
108+
109+
<code>wct <i>path/to/suite</i>
110+
111+
For example:
112+
113+
npm test test/unit/template.html
114+
115+
You can also run tests in the browser:
116+
117+
polyserve
118+
119+
Navigate to [`http://localhost:8080/components/polymer/test/runner.html`](http://localhost:8080/components/polymer/test/runner.html).
120+
121+
### Running Polymer element unit tests
122+
123+
To run the element unit tests, you need a global
124+
install of `web-component-tester` or `polyserve` (or both).
125+
126+
1. Clone the element repo.
127+
128+
2. Install the dependencies.
129+
130+
bower install
131+
132+
3. Run the tests:
133+
134+
wct
135+
136+
Or run the tests in a browser:
137+
138+
polyserve
139+
140+
Navigate to:
141+
142+
<code>http://localhost:8080/components/<var>element-name</var>/test/runner.html</code>
143+
144+
### Configuring `web-component-tester`
145+
146+
By default, `web-component-tester` runs tests on all installed browsers. You can configure it
147+
to run tests on a subset of available browsers, or to run tests remotely using Sauce Labs.
148+
149+
See the [`web-component-tester` README](https://github.com/Polymer/web-component-tester) for
150+
information on configuring the tool.
151+
152+

0 commit comments

Comments
 (0)