https://github.com/codelenny/chai-events
Make assertions about event emitters
https://github.com/codelenny/chai-events
Last synced: about 2 months ago
JSON representation
Make assertions about event emitters
- Host: GitHub
- URL: https://github.com/codelenny/chai-events
- Owner: CodeLenny
- Created: 2017-03-09T19:23:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-16T18:26:50.000Z (over 7 years ago)
- Last Synced: 2025-02-12T06:53:45.111Z (over 1 year ago)
- Language: JavaScript
- Size: 64.5 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Chai Events
[](https://www.browserstack.com/automate/public-build/dHZBczZFaDMraUtrcnNNSTZzVHpRN056ZzU1VHZoclI2S3R6OFRkRGpBYz0tLWcwWndCVUFlTW1jQTlLWjBqc0ZwdVE9PQ==--9ca2d6648ca4fcb5a1bb63e255daf0c6dc46d18c)
Make assertions about event emitters.
```js
const chai = require("chai");
chai.use(require("chai-events"));
const should = chai.should();
const EventEmitter = require("events");
describe("Event Emitting", function() {
let emitter = null;
beforeEach(function() {
emitter = new EventEmitter();
});
it("should get emitted events", function() {
let p = emitter.should.emit("get");
setTimeout(function() {
emitter.emit("get");
}, 200);
return p;
});
it("should handle non-emitted events", function() {
emitter.should.not.emit("missing");
});
it("can be configured", function() {
emitter.should.not.emit("another missing", {
timeout: 50, // in milliseconds
});
});
});
```
## Browser Usage
*Browser testing powered by BrowserStack*
[](https://www.browserstack.com)