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 1
1
# Gemini events
2
2
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
+
3
6
* ` UPDATE_RESULT ` — emitted always during update. The event is emitted with 1 argument ` result ` :
4
7
* ` result.imagePath ` — absolute path to the reference image
5
8
* ` 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 1
1
'use strict' ;
2
2
3
3
module . exports = {
4
+ AFTER_TESTS_READ : 'afterTestsRead' ,
5
+
4
6
START_RUNNER : 'startRunner' ,
5
7
END_RUNNER : 'endRunner' ,
6
8
Original file line number Diff line number Diff line change @@ -116,7 +116,9 @@ module.exports = class Gemini extends PassthroughEmitter {
116
116
applyGrep_ ( options . grep , rootSuite ) ;
117
117
}
118
118
119
- return new SuiteCollection ( rootSuite . children ) ;
119
+ const suiteCollection = new SuiteCollection ( rootSuite . children ) ;
120
+ this . emit ( Events . AFTER_TESTS_READ , { suiteCollection} ) ;
121
+ return suiteCollection ;
120
122
} ) ;
121
123
122
124
function applyGrep_ ( grep , suite ) {
Original file line number Diff line number Diff line change @@ -230,9 +230,16 @@ describe('gemini', () => {
230
230
231
231
it ( 'should return SuiteCollection instance' , ( ) => {
232
232
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} ) ) ;
236
243
} ) ;
237
244
238
245
it ( 'should add to suite collection all read tests excluding root' , ( ) => {
@@ -353,6 +360,15 @@ describe('gemini', () => {
353
360
) ;
354
361
} ) ;
355
362
} ) ;
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
+ } ) ;
356
372
} ) ;
357
373
358
374
describe ( 'environment variables' , ( ) => {
You can’t perform that action at this time.
0 commit comments