This repository was archived by the owner on Sep 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 11# Gemini events
22
3+ * ` AFTER_TESTS_READ ` - emitted after all tests were read (during ` run ` , ` update ` or ` readTests ` call). The event is emitted with 1 argument ` data ` :
4+ * ` data.suiteCollection ` - suite collection with all suites parsed from test files
5+
36* ` UPDATE_RESULT ` — emitted always during update. The event is emitted with 1 argument ` result ` :
47 * ` result.imagePath ` — absolute path to the reference image
58 * ` result.updated ` — boolean value which is ` true ` when reference image have been changed and ` false ` when not
Original file line number Diff line number Diff line change 11'use strict' ;
22
33module . exports = {
4+ AFTER_TESTS_READ : 'afterTestsRead' ,
5+
46 START_RUNNER : 'startRunner' ,
57 END_RUNNER : 'endRunner' ,
68
Original file line number Diff line number Diff line change @@ -116,7 +116,9 @@ module.exports = class Gemini extends PassthroughEmitter {
116116 applyGrep_ ( options . grep , rootSuite ) ;
117117 }
118118
119- return new SuiteCollection ( rootSuite . children ) ;
119+ const suiteCollection = new SuiteCollection ( rootSuite . children ) ;
120+ this . emit ( Events . AFTER_TESTS_READ , { suiteCollection} ) ;
121+ return suiteCollection ;
120122 } ) ;
121123
122124 function applyGrep_ ( grep , suite ) {
Original file line number Diff line number Diff line change @@ -230,9 +230,16 @@ describe('gemini', () => {
230230
231231 it ( 'should return SuiteCollection instance' , ( ) => {
232232 return readTests_ ( )
233- . then ( ( result ) => {
234- assert . instanceOf ( result , SuiteCollection ) ;
235- } ) ;
233+ . then ( ( result ) => assert . instanceOf ( result , SuiteCollection ) ) ;
234+ } ) ;
235+
236+ it ( 'should emit AFTER_TESTS_READ event with created suite collection' , ( ) => {
237+ const onAfterTestRead = sinon . spy ( ) ;
238+ gemini = initGemini ( ) ;
239+ gemini . on ( Events . AFTER_TESTS_READ , onAfterTestRead ) ;
240+
241+ return gemini . readTests ( )
242+ . then ( ( suiteCollection ) => assert . calledOnceWith ( onAfterTestRead , { suiteCollection} ) ) ;
236243 } ) ;
237244
238245 it ( 'should add to suite collection all read tests excluding root' , ( ) => {
@@ -353,6 +360,15 @@ describe('gemini', () => {
353360 ) ;
354361 } ) ;
355362 } ) ;
363+
364+ it ( 'should emit AFTER_TESTS_READ event with suite collection' , ( ) => {
365+ const onAfterTestRead = sinon . spy ( ) ;
366+ gemini = initGemini ( ) ;
367+ gemini . on ( Events . AFTER_TESTS_READ , onAfterTestRead ) ;
368+
369+ return gemini . test ( )
370+ . then ( ( ) => assert . calledOnceWith ( onAfterTestRead , { suiteCollection : sinon . match . instanceOf ( SuiteCollection ) } ) ) ;
371+ } ) ;
356372 } ) ;
357373
358374 describe ( 'environment variables' , ( ) => {
You can’t perform that action at this time.
0 commit comments