Utility classes to help make testing easier


26263.1.03 years ago3 years agoMinified + gzip package size for @beliantech/iron-test-helpers in KB


Published on NPM Build status Published on webcomponents.org


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.


Mock Interactions

This is a set of methods to simulate mouse or keyboard interaction with an element.

import {pressSpace, tap} from '@polymer/iron-test-helpers/mock-interactions.js';

test('can be triggered with space', function(done) {
  button.addEventListener('keydown', function() {

test('can be clicked', function(done) {
  button.addEventListener('click', function() {

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.


If you want to send a PR to this element, here are the instructions for running the tests and demo locally:


git clone https://github.com/PolymerElements/iron-test-helpers
cd iron-test-helpers
npm install
npm install -g polymer-cli

Running the tests

polymer test --npm

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.