https://github.com/rumax/dom-events-mocking
Dom events mocking
https://github.com/rumax/dom-events-mocking
Last synced: 8 months ago
JSON representation
Dom events mocking
- Host: GitHub
- URL: https://github.com/rumax/dom-events-mocking
- Owner: rumax
- License: bsd-2-clause
- Created: 2016-11-03T13:12:26.000Z (over 9 years ago)
- Default Branch: develop
- Last Pushed: 2016-12-27T20:52:10.000Z (over 9 years ago)
- Last Synced: 2025-02-19T08:03:03.182Z (over 1 year ago)
- Language: JavaScript
- Size: 219 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DOM events mocking
[](https://badge.fury.io/js/dom-events-mocking) [](https://circleci.com/gh/rumax/dom-events-mocking)
=============
Wraps the DOM API to make real events mocking in the browser using method chaining.
> npm install --save dome-events
Implements the following DOM events methods and helpers:
- `click`
- `dblclick`
- `drag`
- `at`
- `wait`
- `exec`
- `async`
- `done`
- etc.
## Why Do I Need This?
If you want to test your application and want/can use JavaScript only, but still cover UI events. Or write some integration tests:
```js
it('Can handle my events', (done) => {
const btn = document.getElelemntById('YOUR_BUTTON');
events
.click(btn)
.exec(() => {
expect('YOUR_VALIDATION').toBeTruthy();
})
.click(() => {
// Dynamically created button
return document.getElelemntById('YOUR_NEW_BUTTON');
})
.exec(() => {
expect('YOUR_ANOTHER_VALIDATION').toBeFalsy();
})
.done(() => {
// Final validations
console.log('All steps executed');
done();
});
});
```

Based on [happen](https://www.npmjs.com/package/happen).
## License
BSD-2-Clause