@@ -11,6 +11,7 @@ const run = require('../../lib/interfaces/gherkin');
1111const recorder = require ( '../../lib/recorder' ) ;
1212const container = require ( '../../lib/container' ) ;
1313const actor = require ( '../../lib/actor' ) ;
14+ const event = require ( '../../lib/event' ) ;
1415
1516const text = `
1617 Feature: checkout process
@@ -168,6 +169,25 @@ describe('BDD', () => {
168169 assert . equal ( 'bird' , fn . params [ 0 ] ) ;
169170 } ) ;
170171
172+ it ( 'should produce step events' , ( done ) => {
173+ const text = `
174+ Feature: Emit step event
175+
176+ Scenario:
177+ Then I emit step events
178+ ` ;
179+ Then ( 'I emit step events' , ( ) => { } ) ;
180+ let listeners = 0 ;
181+ event . dispatcher . addListener ( event . bddStep . before , ( ) => listeners ++ ) ;
182+ event . dispatcher . addListener ( event . bddStep . after , ( ) => listeners ++ ) ;
183+
184+ const suite = run ( text ) ;
185+ suite . tests [ 0 ] . fn ( ( ) => {
186+ listeners . should . eql ( 2 ) ;
187+ done ( ) ;
188+ } ) ;
189+ } ) ;
190+
171191 it ( 'should use shortened form for step definitions' , ( ) => {
172192 let fn ;
173193 Given ( 'I am a {word}' , params => params [ 0 ] ) ;
@@ -214,7 +234,7 @@ describe('BDD', () => {
214234 Given I have product with price <price>$ in my cart
215235 And discount is 10 %
216236 Then I should see price is "<total>" $
217-
237+
218238 Examples:
219239 | price | total |
220240 | 10 | 9 |
0 commit comments