File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,40 @@ mocha.run = function (fn) {
167167 } ) ;
168168} ;
169169
170+ /**
171+ * Use HTML notifications instead of Growl
172+ */
173+ Mocha . prototype . _growl = mocha . _growl = function ( runner , reporter ) {
174+ runner . on ( 'end' , function ( ) {
175+ var stats = reporter . stats ;
176+ if ( ! ( 'Notification' in window ) ) return ;
177+ var notification , title , msg ;
178+ if ( stats . failures ) {
179+ title = 'Failed' ;
180+ msg = stats . failures + ' of ' + runner . total + ' tests failed' ;
181+ } else {
182+ title = 'Passed' ;
183+ msg = stats . passes + ' tests passed in ' + stats . duration + 'ms' ;
184+ }
185+ var options = { body : msg } ;
186+ if ( Notification . permission === 'granted' ) {
187+ notification = new Notification ( title , options ) ;
188+ } else if ( Notification . permission !== 'denied' ) {
189+ Notification . requestPermission ( function ( permission ) {
190+ if ( permission === 'granted' ) {
191+ notification = new Notification ( title , options ) ;
192+ }
193+ } ) ;
194+ }
195+ if ( notification ) {
196+ notification . onclick = function ( ) {
197+ window . focus ( ) ;
198+ this . close ( ) ;
199+ } ;
200+ }
201+ } ) ;
202+ } ;
203+
170204/**
171205 * Expose the process shim.
172206 * https://github.com/mochajs/mocha/pull/916
You can’t perform that action at this time.
0 commit comments