https://github.com/polymerelements/iron-test-helpers
Utility classes to make testing easier
https://github.com/polymerelements/iron-test-helpers
Last synced: about 1 year ago
JSON representation
Utility classes to make testing easier
- Host: GitHub
- URL: https://github.com/polymerelements/iron-test-helpers
- Owner: PolymerElements
- Created: 2015-04-22T18:25:31.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2024-10-09T19:04:28.000Z (over 1 year ago)
- Last Synced: 2025-04-05T02:05:36.123Z (about 1 year ago)
- Language: JavaScript
- Size: 255 KB
- Stars: 26
- Watchers: 16
- Forks: 25
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/@polymer/iron-test-helpers)
[](https://travis-ci.org/PolymerElements/iron-test-helpers)
[](https://webcomponents.org/element/@polymer/iron-test-helpers)
## iron-test-helpers
A set of utility classes to make testing easier. For more details on the methods
available, please check the documentation of `mock-interactions.js` and
`test-helpers.js`
See: [Documentation](https://www.webcomponents.org/element/@polymer/iron-test-helpers).
## Usage
### Mock Interactions
This is a set of methods to simulate mouse or keyboard interaction with an
element.
```javascript
import {pressSpace, tap} from '@polymer/iron-test-helpers/mock-interactions.js';
test('can be triggered with space', function(done) {
button.addEventListener('keydown', function() {
done();
});
pressSpace(button);
});
test('can be clicked', function(done) {
button.addEventListener('click', function() {
done();
});
tap(button);
});
```
### Note on globals
Note that in version 3.x, importing `mock-interactions.js` and `test-helpers.js`
will also set the `window.MockInteractions` and `window.TestHelpers` globals,
respectively (and importing `iron-test-helpers.js` will set both). This is done
only for backwards compatibility, and will be removed in the next major version.
All users should migrate away from globals and onto direct ES module imports.
## Contributing
If you want to send a PR to this element, here are
the instructions for running the tests and demo locally:
### Installation
```sh
git clone https://github.com/PolymerElements/iron-test-helpers
cd iron-test-helpers
npm install
npm install -g polymer-cli
```
### Running the tests
```sh
polymer test --npm
```