Skip to content

Commit

Permalink
comment the events
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jan 28, 2017
1 parent 7d25052 commit 97720bf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,31 @@ variable `DEBUG` before running
DEBUG=comment-value node ...
```

The instrumenting function has a global emitter, you can receive messages
when special comments are found and when an expression is wrapped.
For example this code will produce the following events

```js
// index.js
console.log(2 + 40) //> ??
// spec.js
let emitter
beforeEach(() => {
emitter = global.instrument
})
it('finds the comment', () => {
const comments = []
const wrapped = []
emitter.on('comment', c => comments.push(c))
emitter.on('wrap', w => wrapped.push(w))
instrument(source)
// comments will be ["> ??"]
// wrapped will be ["2 + 40"]
})
```

This is an internal feature and is used during unit tests.

### Small print

Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2017
Expand Down

0 comments on commit 97720bf

Please sign in to comment.